﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Text;
using Entity;
using System.Net;
using System.IO;
using Access.BLL;
using System.Configuration;
using YiWangTongBan.BLL;
using Newtonsoft.Json;
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;
using System.Text.RegularExpressions;
//using Spire.Pdf;
//using Spire.Pdf.Graphics;
//using Spire.Pdf.Grid;
//using Spire.Pdf.Widget;
//using Spire.Pdf.Security;
using iTextSharp.text.pdf;
using iTextSharp.text;
using SH3H.CSM.FTP;
using System.Security.Cryptography; 

namespace YiWangTongBan
{
    /*
     * 定义一网通办逻辑类
     * 创建人：方志恩
     * 创建日期：2019/11/25
     */
    public class BusinessLogsticBase
    {
        string STR_CURRENT_COMPANY = ConfigurationManager.AppSettings["CURRENT_COMPANY"];
        string URL_BAOXIU_HOT = ConfigurationManager.AppSettings["URL_BAOXIU_HOT"];
        string XIAODANTIMEOUT = ConfigurationManager.AppSettings["XIAODANTIMEOUT"];
        /// <summary>
        /// 定义验证IncidentID是否存在的方法
        /// </summary>
        /// <param name="incident_id"></param>
        /// <returns></returns>
        public bool IsIncident_IDExist(string incident_id)
        {
            DataTable dt = new AccessDataBase().SelectWF_YIWANGTBSJZBsDynamic(string.Format("INCIDENT_ID='{0}'", incident_id), "", null);
            return dt.Rows.Count > 0 ? false : true;
        }
        public bool IsIncident_IDExistByType(string incident_id, string businessType)
        {
            DataTable dt = new AccessDataBase().SelectWF_YIWANGTBSJZBsDynamic(string.Format("INCIDENT_ID='{0}' ", incident_id) + "AND Business_Type ='" + businessType + "'", "", null);
            return dt.Rows.Count > 0 ? false : true;
        }

        public bool IsApply_no_Exist(string Apply_no)
        {
            DataTable dt = new AccessDataBase().SelectWF_YIWANGTBSJZBsDynamic(string.Format("APPLY_NO='{0}'", Apply_no), "", null);
            return dt.Rows.Count > 0 ? false : true;
        }

        #region 注释代码
        ///////////// <summary>
        ///////////// 根据返回的ID判断写入主表是否成功
        ///////////// </summary>
        ///////////// <param name="rpEntity"></param>
        ///////////// <param name="i_WsNo">接口名称</param>
        ///////////// <returns></returns>
        //////////public bool IsMainInsGoodByID(object rpEntity, int i_WsNo,string _zhubiaobh)
        //////////{
        //////////    WTB_YEWUZB ywzbEntity = null;
        //////////    switch (i_WsNo)
        //////////    {
        //////////        case (int)Web_Service_Name.Repair:
        //////////            #region 报修
        //////////            RepairEntity repairEntity = (RepairEntity)rpEntity;
        //////////            ywzbEntity = new WTB_YEWUZB()
        //////////            {
        //////////                INCIDENT_ID = repairEntity.INCIDENT_ID,
        //////////                S_ZHUBIAOBH = repairEntity.S_ZHUBIAOBH,
        //////////                APPLY_NO = repairEntity.APPLY_NO,
        //////////                CUSTOM_TYPE = repairEntity.CUSTOM_TYPE,
        //////////                SHW_ADDRESS = repairEntity.SHW_ADDRESS,
        //////////                APPLICANT = repairEntity.APPLICANT,
        //////////                APPDATE = repairEntity.APPDATE,
        //////////                INCIDENT_TYPE = repairEntity.INCIDENT_TYPE,
        //////////                CERT_TYPE = repairEntity.CERT_TYPE,
        //////////                CERT_NUMBER = repairEntity.CERT_NUMBER,
        //////////                EMAIL = repairEntity.EMAIL,
        //////////                COMPANY_NAME = repairEntity.COMPANY_NAME,
        //////////                COMPANY_TYPE = repairEntity.COMPANY_TYPE,
        //////////                SOCIAL_CREDIT_CODE = repairEntity.SOCIAL_CREDIT_CODE,
        //////////                CARD_ID = repairEntity.CARD_ID,
        //////////                ADDRESS = repairEntity.ADDRESS,
        //////////                CONTACT_VALUE = repairEntity.CONTACT_VALUE,
        //////////            };
        //////////            #endregion
        //////////            break;
        //////////        case (int)Web_Service_Name.CompanyApply:
        //////////            #region 单位接水
        //////////            CompanyApplyEntity companyApplyEntity = (CompanyApplyEntity)rpEntity;
        //////////            ywzbEntity = new WTB_YEWUZB()
        //////////            {
        //////////                INCIDENT_ID = companyApplyEntity.incident_id,
        //////////                S_ZHUBIAOBH = _zhubiaobh,
        //////////                APPLY_NO = companyApplyEntity.apply_no,
        //////////                SHW_ADDRESS = companyApplyEntity.shw_address,
        //////////                APPLICANT = companyApplyEntity.applicant,
        //////////                APPDATE = companyApplyEntity.appdate,
        //////////                CERT_TYPE = companyApplyEntity.cert_type,
        //////////                CERT_NUMBER = companyApplyEntity.cert_number,
        //////////                EMAIL = companyApplyEntity.email,
        //////////                COMPANY_NAME = companyApplyEntity.company_name,
        //////////                COMPANY_TYPE = companyApplyEntity.company_type,
        //////////                SOCIAL_CREDIT_CODE = companyApplyEntity.social_credit_code,
        //////////                BUSINESS_TYPE = companyApplyEntity.business_type,
        //////////                ADDRESS=companyApplyEntity.address,
        //////////                APPLY_CONTENT=companyApplyEntity.apply_content,
        //////////                //project
        //////////                //contact_person
        //////////                MAIL = companyApplyEntity.MAIL
        //////////            };
        //////////            #endregion
        //////////            break;
        //////////        case (int)Web_Service_Name.ResidentApply:
        //////////            #region 居民住宅单独接水
        //////////            ResidentApplyEntity residentApplyEntity = (ResidentApplyEntity)rpEntity;
        //////////            ywzbEntity = new WTB_YEWUZB()
        //////////            {
        //////////                INCIDENT_ID = residentApplyEntity.incident_id,
        //////////                S_ZHUBIAOBH = _zhubiaobh,
        //////////                APPLY_NO = residentApplyEntity.apply_no,
        //////////                SHW_ADDRESS = residentApplyEntity.shw_address,
        //////////                APPLICANT = residentApplyEntity.applicant,
        //////////                APPDATE = residentApplyEntity.appdate,
        //////////                INCIDENT_TYPE = residentApplyEntity.incident_type,
        //////////                CERT_TYPE = residentApplyEntity.cert_type,
        //////////                CERT_NUMBER = residentApplyEntity.cert_number,
        //////////                BUSINESS_TYPE = residentApplyEntity.business_type,
        //////////                ADDRESS = residentApplyEntity.address,
        //////////                APPLY_CONTENT = residentApplyEntity.apply_content,
        //////////                CON_NAME = residentApplyEntity.con_name,
        //////////                PHONE = residentApplyEntity.phone,
        //////////                MAIL = residentApplyEntity.mail,
        //////////                WYGZ = residentApplyEntity.wygz
        //////////            };
        //////////            #endregion
        //////////            break;
        //////////        case (int)Web_Service_Name.Transfer:
        //////////            #region 居民过户/单位过户
        //////////            TransferEntity transferEntity = (TransferEntity)rpEntity;
        //////////            ywzbEntity = new WTB_YEWUZB()
        //////////            {
        //////////                INCIDENT_ID = transferEntity.INCIDENT_ID,
        //////////                S_ZHUBIAOBH = transferEntity.S_ZHUBIAOBH,
        //////////                APPLY_NO = transferEntity.APPLY_NO,
        //////////                CUSTOM_TYPE = transferEntity.CUSTOM_TYPE,
        //////////                APPLICANT = transferEntity.APPLICANT,
        //////////                APPDATE = transferEntity.APPDATE,
        //////////                CERT_TYPE = transferEntity.CERT_TYPE,
        //////////                CERT_NUMBER = transferEntity.CERT_NUMBER,
        //////////                EMAIL = transferEntity.EMAIL,
        //////////                COMPANY_NAME = transferEntity.COMPANY_NAME,
        //////////                COMPANY_TYPE = transferEntity.COMPANY_TYPE,
        //////////                BUSINESS_TYPE = transferEntity.BUSINESS_TYPE,
        //////////                CARD_ID = transferEntity.CARD_ID
        //////////            };
        //////////            #endregion
        //////////            break;
        //////////        case (int)Web_Service_Name.WatermeterSplit:
        //////////            #region 居民住宅总表分装
        //////////            WatermeterSplitEntity waterSplitEntity = (WatermeterSplitEntity)rpEntity;
        //////////            ywzbEntity = new WTB_YEWUZB()
        //////////            {
        //////////                INCIDENT_ID = waterSplitEntity.INCIDENT_ID,
        //////////                S_ZHUBIAOBH = waterSplitEntity.S_ZHUBIAOBH,
        //////////                APPLY_NO = waterSplitEntity.APPLY_NO,
        //////////                SHW_ADDRESS = waterSplitEntity.SHW_ADDRESS,
        //////////                APPLICANT = waterSplitEntity.APPLICANT,
        //////////                APPDATE = waterSplitEntity.APPDATE,
        //////////                INCIDENT_TYPE = waterSplitEntity.INCIDENT_TYPE,
        //////////                CERT_TYPE = waterSplitEntity.CERT_TYPE,
        //////////                CERT_NUMBER = waterSplitEntity.CERT_NUMBER,
        //////////                EMAIL = waterSplitEntity.EMAIL,
        //////////                BUSINESS_TYPE = waterSplitEntity.BUSINESS_TYPE,
        //////////                ADDRESS = waterSplitEntity.ADDRESS,
        //////////                CON_NAME = waterSplitEntity.CON_NAME,
        //////////                CONTACT_VALUE = waterSplitEntity.CONTACT_VALUE,
        //////////                PHONE = waterSplitEntity.PHONE,
        //////////                MAIL = waterSplitEntity.MAIL,
        //////////                WYGZ = waterSplitEntity.WYGZ
        //////////            };
        //////////            #endregion
        //////////            break;
        //////////    }
        //////////    int i_Rtn_ID = new AccessDataBase().InsertTB_YEWUZB(ywzbEntity, null);
        //////////    return i_Rtn_ID > 0 ? true : false;
        //////////}

        /////////////// <summary>
        /////////////// 根据返回的result判断写入子表是否成功
        /////////////// </summary>
        /////////////// <param name="rpEntity"></param>
        /////////////// <param name="i_WsNo">接口名称</param>
        /////////////// <returns></returns>
        ////////////public bool IsChildInsGoodByResult(object rpEntity, int i_WsNo)
        ////////////{
        ////////////    int i_Rtn_Result = 0;
        ////////////    switch (i_WsNo)
        ////////////    {
        ////////////        case (int)Web_Service_Name.Repair:
        ////////////            #region 报修
        ////////////            RepairEntity repairEntity = (RepairEntity)rpEntity;
        ////////////            WTB_BAOXIUXX bxEntity = new WTB_BAOXIUXX()
        ////////////            {
        ////////////                S_ZHUBIAOBH = repairEntity.S_ZHUBIAOBH,
        ////////////                INCIDENT_ID = repairEntity.INCIDENT_ID,
        ////////////                CASE_TYPE_CD = repairEntity.CASE_TYPE_CD,
        ////////////                FYLY = repairEntity.FYLY,
        ////////////                FYXS = repairEntity.FYXS,
        ////////////                FYQM = repairEntity.FYQM,
        ////////////                FYLB = repairEntity.FYLB,
        ////////////                FYNR = repairEntity.FYNR,
        ////////////                BX_DTTM = repairEntity.BX_DTTM.ToString(),
        ////////////                CLJB = repairEntity.CLJB,
        ////////////                CN_DTTM = repairEntity.CN_DTTM.ToString(),
        ////////////                BX_LOC_CD = repairEntity.BX_LOC_CD,
        ////////////                REPAIR_COMMENT = repairEntity.REPAIR_COMMENT
        ////////////            };

        ////////////            #endregion
        ////////////            i_Rtn_Result = new AccessDataBase().InsertWTB_BAOXIUXX(bxEntity, null);
        ////////////            break;
        ////////////        case (int)Web_Service_Name.CompanyApply:
        ////////////            #region 单位接水
        ////////////            CompanyApplyEntity companyApplyEntity = (CompanyApplyEntity)rpEntity;
        ////////////            WTB_JIESHUIXX jsxxEntity = new WTB_JIESHUIXX()
        ////////////            {
        ////////////                S_ZHUBIAOBH = companyApplyEntity.S_ZHUBIAOBH,
        ////////////                INCIDENT_ID = companyApplyEntity.INCIDENT_ID,
        ////////////                S_TYPE = "单位接水",
        ////////////                CONTACT_ADDRESS = companyApplyEntity.SHW_ADDRESS,
        ////////////                S_PROJECT = companyApplyEntity.PROJECT,
        ////////////                CONTACT_PERSON = companyApplyEntity.CONTACT_PERSON,
        ////////////                YSXQSC = companyApplyEntity.ToString(),
        ////////////                YSXQXF = companyApplyEntity.ToString(),
        ////////////                OVERALL_FLOORAGE = companyApplyEntity.OVERALL_FLOORAGE,
        ////////////                QYZJLX = companyApplyEntity.QYZJLX,
        ////////////                QYZJBM = companyApplyEntity.QYZJBM,
        ////////////                FRXM = companyApplyEntity.FRXM,
        ////////////                FRSFZHM = companyApplyEntity.FRSFZHM,
        ////////////                YDXZ = companyApplyEntity.YDXZ,
        ////////////                BUILD_TYPE = companyApplyEntity.BUILD_TYPE,
        ////////////                WYGZ = companyApplyEntity.WYGZ,
        ////////////                KHXZ = companyApplyEntity.KHXZ,
        ////////////                SQLB = companyApplyEntity.SQLB
        ////////////            };
        ////////////            #endregion
        ////////////            i_Rtn_Result = new AccessDataBase().InsertWTB_JIESHUIXX(jsxxEntity, null);
        ////////////            break;
        ////////////        case (int)Web_Service_Name.ResidentApply:
        ////////////            #region 居民住宅单独接水
        ////////////            ResidentApplyEntity residentApplyEntity = (ResidentApplyEntity)rpEntity;
        ////////////            WTB_JIESHUIXX jmzzddjsEntity = new WTB_JIESHUIXX()
        ////////////            {
        ////////////                S_ZHUBIAOBH = residentApplyEntity.S_ZHUBIAOBH,
        ////////////                INCIDENT_ID = residentApplyEntity.INCIDENT_ID,
        ////////////                CONTACT_ADDRESS = residentApplyEntity.CONTACT_ADDRESS
        ////////////            };
        ////////////            #endregion
        ////////////            i_Rtn_Result = new AccessDataBase().InsertWTB_JIESHUIXX(jmzzddjsEntity, null);
        ////////////            break;
        ////////////        case (int)Web_Service_Name.Transfer:
        ////////////            #region 居民过户/单位过户
        ////////////            TransferEntity transferEntity = (TransferEntity)rpEntity;
        ////////////            WTB_GUOHUXX ghEntity = new WTB_GUOHUXX()
        ////////////            {
        ////////////                S_ZHUBIAOBH = transferEntity.S_ZHUBIAOBH,
        ////////////                INCIDENT_ID = transferEntity.INCIDENT_ID,
        ////////////                NEW_ENTITY_NAME = transferEntity.NEW_ENTITY_NAME,
        ////////////                ID_TYPE = transferEntity.ID_TYPE,
        ////////////                ID_NBR = transferEntity.ID_NBR,
        ////////////                FCZJLX = transferEntity.FCZJLX,
        ////////////                FCZJHM = transferEntity.FCZJHM,
        ////////////                ADDRESS = transferEntity.ADDRESS,
        ////////////                COMM_RTE_TYPE_CD = transferEntity.COMM_RTE_TYPE_CD,
        ////////////                CONTACT_VALUE = transferEntity.CONTACT_VALUE,
        ////////////                GYSHTBH = transferEntity.GYSHTBH,
        ////////////                FPLX = transferEntity.FPLX,
        ////////////                FPTT = transferEntity.FPTT,
        ////////////                NSRSBH = transferEntity.NSRSBH,
        ////////////                YSRKS = transferEntity.YSRKS,
        ////////////                TRANSFER_COMMENT = transferEntity.TRANSFER_COMMENT,
        ////////////                TYPC = transferEntity.TYPC
        ////////////            };
        ////////////            i_Rtn_Result = new AccessDataBase().InsertWTB_GUOHUXX(ghEntity, null);
        ////////////            #endregion
        ////////////            break;
        ////////////        case (int)Web_Service_Name.WatermeterSplit:
        ////////////            #region 居民住宅总表分装
        ////////////            WatermeterSplitEntity waterSplitEntity = (WatermeterSplitEntity)rpEntity;
        ////////////            WTB_JUMINZGFXX zgfEntity = new WTB_JUMINZGFXX()
        ////////////            {
        ////////////                S_ZHUBIAOBH = waterSplitEntity.S_ZHUBIAOBH,
        ////////////                INCIDENT_ID = waterSplitEntity.INCIDENT_ID,
        ////////////                YB = waterSplitEntity.YB,
        ////////////                SPLIT_COMMENT = waterSplitEntity.SPLIT_COMMENT,
        ////////////                WYGZ = waterSplitEntity.WYGZ
        ////////////            };
        ////////////            i_Rtn_Result = new AccessDataBase().InsertWTB_JUMINZGFXX(zgfEntity, null);
        ////////////            #endregion
        ////////////            break;
        ////////////    }
        ////////////    return i_Rtn_Result > 0 ? true : false;
        ////////////}
        #endregion
        /// <summary>
        /// 插入主表数据
        /// </summary>
        /// <param name="_ywzbEntity"></param>
        /// <returns></returns>
        public bool IsMainInsGoodByID(WTB_YEWUZB _ywzbEntity)
        {
            int i_Rtn_ID = new AccessDataBase().InsertTB_YEWUZB(_ywzbEntity, null);
            return i_Rtn_ID > 0 ? true : false;
        }

        #region 将接口实体转换成数据表实体
        /// <summary>
        /// 创建报修实体
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_BAOXIUXX"></param>
        public void CreateRepairEntity(RepairEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out WTB_BAOXIUXX _WTB_BAOXIUXX)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_BAOXIUXX _outWTB_BAOXIUXX = new WTB_BAOXIUXX();
            List<repairFile> _outfiles = new List<repairFile>();
            //数据表基础信息赋值
            _outWTB_YEWUZB.ID = 0;
            _outWTB_BAOXIUXX.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = getBusinessType(rpEntity.incident_type) + GetTimeStamp();
            _outWTB_BAOXIUXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
            _outWTB_YEWUZB.BUSINESS_TYPE = getBusinessType(rpEntity.incident_type);
            _outWTB_YEWUZB.D_JIESHOUSJ = DateTime.Now;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;//处理中
            _outWTB_YEWUZB.IS_TRANSFER_ORDER = rpEntity.is_transfer_order;
            _outWTB_YEWUZB.SHW_COMPANY_SOURCE = rpEntity.shw_company_source;

            //一网同步接口字段赋值
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.CUSTOM_TYPE = rpEntity.custom_type;
            _outWTB_YEWUZB.SHW_ADDRESS = rpEntity.shw_address;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.INCIDENT_TYPE = rpEntity.incident_type;
            _outWTB_YEWUZB.CERT_TYPE = rpEntity.cert_type;
            _outWTB_YEWUZB.CERT_NUMBER = rpEntity.cert_number;
            _outWTB_YEWUZB.EMAIL = rpEntity.email;
            _outWTB_YEWUZB.COMPANY_NAME = rpEntity.company_name;
            _outWTB_YEWUZB.COMPANY_TYPE = rpEntity.company_type;
            _outWTB_YEWUZB.SOCIAL_CREDIT_CODE = rpEntity.social_credit_code;
            _outWTB_BAOXIUXX.CASE_TYPE_CD = rpEntity.case_type_cd;
            _outWTB_YEWUZB.CARD_ID = rpEntity.card_id;
            _outWTB_YEWUZB.ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.CONTACT_VALUE = rpEntity.contact_value;
            _outWTB_YEWUZB.S_BEIYOGN3 = rpEntity.source;

            _outWTB_BAOXIUXX.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_BAOXIUXX.FYLY = rpEntity.fyly;
            _outWTB_BAOXIUXX.FYXS = rpEntity.fyxs;
            _outWTB_BAOXIUXX.FYQM = rpEntity.fyqm;
            _outWTB_BAOXIUXX.FYLB = rpEntity.fylb;
            _outWTB_BAOXIUXX.FYNR = rpEntity.fynr;
            _outWTB_BAOXIUXX.BX_DTTM = rpEntity.bx_dttm;
            _outWTB_BAOXIUXX.CLJB = rpEntity.cljb;
            _outWTB_BAOXIUXX.CN_DTTM = rpEntity.cn_dttm;
            _outWTB_BAOXIUXX.BX_LOC_CD = rpEntity.bx_loc_cd;
            _outWTB_BAOXIUXX.REPAIR_COMMENT = rpEntity.repair_comment;


            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_BAOXIUXX = _outWTB_BAOXIUXX;
        }

        /// <summary>
        /// 创建单位接水实体
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_BAOXIUXX"></param>
        public void CreateCompanyApplyEntity(CompanyApplyEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out WTB_JIESHUIXX _WTB_JIESHUIXX)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_JIESHUIXX _outWTB_JIESHUIXX = new WTB_JIESHUIXX();

            //数据表基础信息赋值
            _outWTB_YEWUZB.ID = 0;
            _outWTB_JIESHUIXX.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = "02" + GetTimeStamp();//此处为incident_type+ GetTimeStamp()
            _outWTB_JIESHUIXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
            _outWTB_YEWUZB.D_JIESHOUSJ = DateTime.Now;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;//处理中

            //一网同步接口字段赋值
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.SHW_ADDRESS = rpEntity.shw_address;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.APPDATE = UnixTimeToDateTimeStr((Convert.ToInt32(rpEntity.appdate)));
            _outWTB_YEWUZB.INCIDENT_TYPE = "02";//此处为incident_type
            _outWTB_YEWUZB.CERT_TYPE = rpEntity.cert_type;
            _outWTB_YEWUZB.CERT_NUMBER = rpEntity.cert_number;
            _outWTB_YEWUZB.EMAIL = rpEntity.email;
            _outWTB_YEWUZB.COMPANY_NAME = rpEntity.company_name;
            _outWTB_YEWUZB.COMPANY_TYPE = rpEntity.company_type;
            _outWTB_YEWUZB.SOCIAL_CREDIT_CODE = rpEntity.social_credit_code;
            _outWTB_YEWUZB.ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.PHONE = rpEntity.phone;
            _outWTB_YEWUZB.BUSINESS_TYPE = rpEntity.business_type;
            _outWTB_YEWUZB.APPLY_CONTENT = rpEntity.apply_content;
            _outWTB_YEWUZB.MAIL = rpEntity.mail;

            _outWTB_JIESHUIXX.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_JIESHUIXX.S_PROJECT = rpEntity.project;
            _outWTB_JIESHUIXX.CONTACT_PERSON = rpEntity.contact_person;
            _outWTB_JIESHUIXX.YSXQSC = rpEntity.ysxqsc;
            _outWTB_JIESHUIXX.YSXQXF = rpEntity.ysxqxf;
            _outWTB_JIESHUIXX.OVERALL_FLOORAGE = rpEntity.overall_floorage;
            _outWTB_JIESHUIXX.QYZJLX = rpEntity.qyzjlx;
            _outWTB_JIESHUIXX.QYZJBM = rpEntity.qyzjbm;
            _outWTB_JIESHUIXX.FRXM = rpEntity.frxm;
            _outWTB_JIESHUIXX.FRSFZHM = rpEntity.frsfzhm;
            _outWTB_JIESHUIXX.YDXZ = rpEntity.ydxz;
            _outWTB_JIESHUIXX.BUILD_TYPE = rpEntity.build_type;
            _outWTB_JIESHUIXX.WYGZ = rpEntity.wygz;
            _outWTB_JIESHUIXX.KHXZ = rpEntity.khxz;
            _outWTB_JIESHUIXX.SQLB = rpEntity.sqlb;
            _outWTB_JIESHUIXX.CONTACT_PERSON = rpEntity.contact_person;

            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_JIESHUIXX = _outWTB_JIESHUIXX;
        }

        /// <summary>
        /// 创建居民住宅单独接水实体
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_BAOXIUXX"></param>
        public void CreateResidentEntity(ResidentApplyEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out WTB_JIESHUIXX _WTB_JIESHUIXX)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_JIESHUIXX _outWTB_JIESHUIXX = new WTB_JIESHUIXX();

            //数据表基础信息赋值
            _outWTB_YEWUZB.ID = 0;
            _outWTB_JIESHUIXX.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = "01" + GetTimeStamp();
            _outWTB_JIESHUIXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
            _outWTB_YEWUZB.D_JIESHOUSJ = DateTime.Now;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;//处理中
            _outWTB_YEWUZB.IS_TRANSFER_ORDER = rpEntity.is_transfer_order;
            _outWTB_YEWUZB.SHW_COMPANY_SOURCE = rpEntity.shw_company_source;

            //一网同步接口字段赋值
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.SHW_ADDRESS = rpEntity.shw_address;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.INCIDENT_TYPE = rpEntity.incident_type;
            _outWTB_YEWUZB.CERT_TYPE = rpEntity.cert_type;
            _outWTB_YEWUZB.CERT_NUMBER = rpEntity.cert_number;
            _outWTB_YEWUZB.ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.PHONE = rpEntity.phone;
            _outWTB_YEWUZB.BUSINESS_TYPE = rpEntity.business_type;
            _outWTB_YEWUZB.APPLY_CONTENT = rpEntity.apply_content;
            _outWTB_YEWUZB.MAIL = rpEntity.mail;
            _outWTB_YEWUZB.CON_NAME = rpEntity.con_name;

            _outWTB_JIESHUIXX.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_JIESHUIXX.CONTACT_ADDRESS = rpEntity.contact_address;
            _outWTB_JIESHUIXX.FCZHM = rpEntity.fczhm;
            _outWTB_JIESHUIXX.FENSUO = rpEntity.fensuo;
            _outWTB_JIESHUIXX.XZQ = rpEntity.xzq;
            _outWTB_JIESHUIXX.JDZ = rpEntity.jdz;
            _outWTB_JIESHUIXX.APPLY_MEMO = rpEntity.apply_memo;
            _outWTB_JIESHUIXX.S_BEIYONG1 = rpEntity.source;

            
            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_JIESHUIXX = _outWTB_JIESHUIXX;
        }

        /// <summary>
        /// 创建居民过户/单位过户实体
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_BAOXIUXX"></param>
        public void CreateTransferEntity(TransferEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out WTB_GUOHUXX _WTB_GUOHUXX)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_GUOHUXX _outWTB_GUOHUXX = new WTB_GUOHUXX();

            //数据表基础信息赋值
            _outWTB_YEWUZB.ID = 0;
            _outWTB_GUOHUXX.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = rpEntity.business_type + GetTimeStamp();//此处为incident_type+ GetTimeStamp()
            _outWTB_GUOHUXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
            _outWTB_YEWUZB.D_JIESHOUSJ = DateTime.Now;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;//处理中
            _outWTB_YEWUZB.IS_TRANSFER_ORDER = rpEntity.is_transfer_order;
            _outWTB_YEWUZB.SHW_COMPANY_SOURCE = rpEntity.shw_company_source;

            //一网通办接口字段赋值
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.INCIDENT_TYPE = rpEntity.business_type == "14" ? "McsItemType.RepairResidentTransfer" : "McsItemType.RepairCompanyTransfer";//"15";//此处为incident_type
            _outWTB_YEWUZB.CERT_TYPE = rpEntity.cert_type;
            _outWTB_YEWUZB.CERT_NUMBER = rpEntity.cert_number;
            _outWTB_YEWUZB.ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.BUSINESS_TYPE = rpEntity.business_type;
            _outWTB_YEWUZB.CUSTOM_TYPE = rpEntity.custom_type;
            _outWTB_YEWUZB.EMAIL = rpEntity.email;
            _outWTB_YEWUZB.COMPANY_NAME = rpEntity.company_name;
            _outWTB_YEWUZB.COMPANY_TYPE = rpEntity.company_type;
            _outWTB_YEWUZB.CARD_ID = rpEntity.card_id;
            _outWTB_YEWUZB.BILL_ADDRESS = rpEntity.bill_address;

            _outWTB_GUOHUXX.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_GUOHUXX.ADDRESS = rpEntity.address;
            _outWTB_GUOHUXX.NEW_ENTITY_NAME = rpEntity.new_entity_name;
            _outWTB_GUOHUXX.ID_TYPE = rpEntity.id_type;
            _outWTB_GUOHUXX.ID_NBR = rpEntity.id_nbr;
            _outWTB_GUOHUXX.FCZJLX = rpEntity.fczjlx;
            _outWTB_GUOHUXX.FCZJHM = rpEntity.fczjhm;
            _outWTB_GUOHUXX.COMM_RTE_TYPE_CD = rpEntity.comm_rte_type_cd;
            _outWTB_GUOHUXX.CONTACT_VALUE = rpEntity.contact_value;
            _outWTB_GUOHUXX.GYSHTBH = rpEntity.gyshtbh;
            _outWTB_GUOHUXX.FPLX = rpEntity.fplx;
            _outWTB_GUOHUXX.FPTT = rpEntity.fptt;
            _outWTB_GUOHUXX.NSRSBH = rpEntity.nsrsbh;
            _outWTB_GUOHUXX.YSRKS = rpEntity.ysrks;
            _outWTB_GUOHUXX.TRANSFER_COMMENT = rpEntity.transfer_comment;
            _outWTB_GUOHUXX.TYPC = rpEntity.typc;
            _outWTB_GUOHUXX.METER_NUMBER = rpEntity.meter_number;
            _outWTB_GUOHUXX.S_BEIYONG2 = rpEntity.business_type == "14" ? "居民过户" : "单位过户";//"居民/单位过户";
            _outWTB_GUOHUXX.TRANSFER_REASON = rpEntity.transfer_reason;
            _outWTB_GUOHUXX.USE_TYPE = rpEntity.use_type;
            _outWTB_GUOHUXX.CONTACTS = rpEntity.contacts;
            _outWTB_GUOHUXX.CONTACT_NUM = rpEntity.contact_num;
            _outWTB_GUOHUXX.FYLY = rpEntity.source;
            _outWTB_GUOHUXX.S_BEIYONG3 = rpEntity.location;

            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_GUOHUXX = _outWTB_GUOHUXX;
        }
        /// <summary>
        /// 联合过户
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_GUOHUXX"></param>
        public void CreateuniTransferEntity(uniTransferEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out WTB_GUOHUXX _WTB_GUOHUXX)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_GUOHUXX _outWTB_GUOHUXX = new WTB_GUOHUXX();
            string business_type = "26";
            //数据表基础信息赋值
            _outWTB_YEWUZB.ID = 0;
            _outWTB_GUOHUXX.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = business_type + GetTimeStamp();//此处为incident_type+ GetTimeStamp()
            _outWTB_GUOHUXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
            _outWTB_YEWUZB.D_JIESHOUSJ = DateTime.Now;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;//处理中
            //_outWTB_YEWUZB.IS_TRANSFER_ORDER = rpEntity.is_transfer_order;
            //_outWTB_YEWUZB.SHW_COMPANY_SOURCE = rpEntity.shw_company_source;
           
            //一网通办接口字段赋值
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.INCIDENT_TYPE = "McsItemType.ResidentUnionTransfer";//此处为incident_type
            _outWTB_YEWUZB.CERT_TYPE = rpEntity.cert_type;
            _outWTB_YEWUZB.CERT_NUMBER = rpEntity.cert_number;
            _outWTB_YEWUZB.ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.BUSINESS_TYPE = business_type;
            _outWTB_YEWUZB.CUSTOM_TYPE = "01";
            _outWTB_YEWUZB.EMAIL = rpEntity.email;
            //_outWTB_YEWUZB.COMPANY_NAME = rpEntity.company_name;
            //_outWTB_YEWUZB.COMPANY_TYPE = rpEntity.company_type;
            _outWTB_YEWUZB.CARD_ID = rpEntity.card_id;
            //_outWTB_YEWUZB.BILL_ADDRESS = rpEntity.bill_address;

            _outWTB_GUOHUXX.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_GUOHUXX.ADDRESS = rpEntity.address;
            _outWTB_GUOHUXX.NEW_ENTITY_NAME = rpEntity.applicant;//rpEntity.new_entity_name;
            _outWTB_GUOHUXX.ID_TYPE = rpEntity.cert_type;//rpEntity.id_type;
            _outWTB_GUOHUXX.ID_NBR = rpEntity.cert_number;//rpEntity.id_nbr;
            _outWTB_GUOHUXX.FCZJLX = rpEntity.fczjlx;
            _outWTB_GUOHUXX.FCZJHM = rpEntity.fczjhm;
            //_outWTB_GUOHUXX.COMM_RTE_TYPE_CD = rpEntity.comm_rte_type_cd;
            _outWTB_GUOHUXX.CONTACT_VALUE = rpEntity.contact_num;//rpEntity.contact_value;
            //_outWTB_GUOHUXX.GYSHTBH = rpEntity.gyshtbh;
            //_outWTB_GUOHUXX.FPLX = rpEntity.fplx;
            //_outWTB_GUOHUXX.FPTT = rpEntity.fptt;
            //_outWTB_GUOHUXX.NSRSBH = rpEntity.nsrsbh;
            //_outWTB_GUOHUXX.YSRKS = rpEntity.ysrks;
            //_outWTB_GUOHUXX.TRANSFER_COMMENT = rpEntity.transfer_comment;
            //_outWTB_GUOHUXX.TYPC = rpEntity.typc;
            //_outWTB_GUOHUXX.METER_NUMBER = rpEntity.meter_number;
            _outWTB_GUOHUXX.S_BEIYONG2 =  "居民联合过户";//"居民/单位过户";
            //_outWTB_GUOHUXX.TRANSFER_REASON = rpEntity.transfer_reason;
            //_outWTB_GUOHUXX.USE_TYPE = rpEntity.use_type;
            _outWTB_GUOHUXX.CONTACTS = rpEntity.applicant;//rpEntity.contacts;
            _outWTB_GUOHUXX.CONTACT_NUM = rpEntity.contact_num;
            _outWTB_GUOHUXX.S_BEIYONG3 = rpEntity.bdczl + "|" + rpEntity.passdate + "|" + rpEntity.location + "|" + rpEntity.bdcID+"|"+rpEntity.rightno+"|"+rpEntity.bdcsh;//坐落|不动产登簿日期|不动产坐落|不动产登记业务号|不动产权证号|室号--居民联合过户
            _outWTB_GUOHUXX.D_BEIYONG1 = Convert.ToDateTime(rpEntity.passdate);
            _outWTB_GUOHUXX.FYLY = rpEntity.source;


            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_GUOHUXX = _outWTB_GUOHUXX;
        }

        /// <summary>
        /// 创建实名制实体类
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_GUOHUXX"></param>
        public void CreateRealNameEntity(RealNameEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out WTB_GUOHUXX _WTB_GUOHUXX)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_GUOHUXX _outWTB_GUOHUXX = new WTB_GUOHUXX();

            //数据表基础信息赋值
            _outWTB_YEWUZB.ID = 0;
            _outWTB_GUOHUXX.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = rpEntity.business_type + GetTimeStamp();//此处为incident_type+ GetTimeStamp(),暂时将实名制incident_type设定为17
            _outWTB_GUOHUXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
            _outWTB_YEWUZB.D_JIESHOUSJ = DateTime.Now;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;//处理中
            _outWTB_YEWUZB.IS_TRANSFER_ORDER = rpEntity.is_transfer_order;
            _outWTB_YEWUZB.SHW_COMPANY_SOURCE = rpEntity.shw_company_source;

            //一网同步接口字段赋值
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.INCIDENT_TYPE = "McsItemType.RealNameRegiste";//此处为incident_type,暂时将实名制incident_type设定为17
            _outWTB_YEWUZB.ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.BUSINESS_TYPE = rpEntity.business_type;
            _outWTB_YEWUZB.CUSTOM_TYPE = rpEntity.business_type == "17" ? "01" : "02";// rpEntity.custom_type;
            _outWTB_YEWUZB.CARD_ID = rpEntity.card_id;
            _outWTB_YEWUZB.EMAIL = rpEntity.email;
            _outWTB_YEWUZB.COMPANY_NAME = rpEntity.company_name;

            //子表字段
            _outWTB_GUOHUXX.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_GUOHUXX.ID_TYPE = rpEntity.id_type;
            _outWTB_GUOHUXX.ID_NBR = rpEntity.id_nbr;
            _outWTB_GUOHUXX.FCZJLX = rpEntity.fczjlx;
            _outWTB_GUOHUXX.FCZJHM = rpEntity.fczjhm;
            _outWTB_GUOHUXX.ADDRESS = rpEntity.address;
            _outWTB_GUOHUXX.CONTACT_VALUE = rpEntity.contact_value;
            _outWTB_GUOHUXX.NSRSBH = rpEntity.social_credit_code;
            _outWTB_GUOHUXX.ENTITY_NAME = rpEntity.business_type == "17" ? rpEntity.applicant : rpEntity.company_name;
            _outWTB_GUOHUXX.S_BEIYONG2 = "实名制";
            _outWTB_GUOHUXX.FYLY = rpEntity.source;
            _outWTB_GUOHUXX.S_BEIYONG3 = rpEntity.location;

            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_GUOHUXX = _outWTB_GUOHUXX;
        }

        /// <summary>
        /// 创建居民住宅总表分装
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_GUOHUXX"></param>
        public void CreateWatermeterSplitEntity(WatermeterSplitEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out WTB_JUMINZGFXX _WTB_JUMINZGFXX)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_JUMINZGFXX _outWTB_JUMINZGFXX = new WTB_JUMINZGFXX();

            //数据表基础信息赋值
            _outWTB_YEWUZB.ID = 0;
            _outWTB_JUMINZGFXX.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = "16" + GetTimeStamp();
            _outWTB_JUMINZGFXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
            _outWTB_YEWUZB.D_JIESHOUSJ = DateTime.Now;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;//处理中
            _outWTB_YEWUZB.IS_TRANSFER_ORDER = rpEntity.is_transfer_order;
            _outWTB_YEWUZB.SHW_COMPANY_SOURCE = rpEntity.shw_company_source;

            //一网同步接口字段赋值
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.INCIDENT_TYPE = rpEntity.incident_type;
            _outWTB_YEWUZB.CERT_TYPE = rpEntity.cert_type;
            _outWTB_YEWUZB.CERT_NUMBER = rpEntity.cert_number;
            _outWTB_YEWUZB.ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.BUSINESS_TYPE = rpEntity.business_type;
            _outWTB_YEWUZB.CARD_ID = rpEntity.card_id;
            _outWTB_YEWUZB.EMAIL = rpEntity.email;
            _outWTB_YEWUZB.SHW_ADDRESS = rpEntity.shw_address;
            _outWTB_YEWUZB.CON_NAME = rpEntity.con_name;
            _outWTB_YEWUZB.CONTACT_VALUE = rpEntity.contact_value;
            _outWTB_YEWUZB.PHONE = rpEntity.phone;
            _outWTB_YEWUZB.MAIL = rpEntity.mail;

            _outWTB_JUMINZGFXX.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_JUMINZGFXX.YB = rpEntity.yb;
            _outWTB_JUMINZGFXX.SPLIT_COMMENT = rpEntity.split_comment;
            _outWTB_JUMINZGFXX.FENSUO = rpEntity.fensuo;
            _outWTB_JUMINZGFXX.XZQ = rpEntity.xzq;
            _outWTB_JUMINZGFXX.JDZ = rpEntity.jdz;
            _outWTB_JUMINZGFXX.S_BEIYONG1 = rpEntity.source;

            
            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_JUMINZGFXX = _outWTB_JUMINZGFXX;
        }

        /// <summary>
        /// 创建一户多人口实体
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_GUOHUXX"></param>
        public void CreatemultiPopulationEntity(multiPopulationEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out WTB_YIHUDRKXX _WTB_YIHUDRKXX)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_YIHUDRKXX _outWTB_YIHUDRKXX = new WTB_YIHUDRKXX();
            string business_type = "25";

            //数据表基础信息赋值
            _outWTB_YEWUZB.ID = 0;
            _outWTB_YIHUDRKXX.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = business_type + GetTimeStamp();//此处为incident_type+ GetTimeStamp()
            _outWTB_YIHUDRKXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
            _outWTB_YEWUZB.D_JIESHOUSJ = DateTime.Now;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;//处理中
            _outWTB_YEWUZB.IS_TRANSFER_ORDER = "0";
            _outWTB_YEWUZB.SHW_COMPANY_SOURCE = "";

            //一网通办接口字段赋值
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.INCIDENT_TYPE = "McsItemType.MultiHousehold";//此处为incident_type
            _outWTB_YEWUZB.CERT_TYPE = rpEntity.cert_type;
            _outWTB_YEWUZB.CERT_NUMBER = rpEntity.cert_number;
            _outWTB_YEWUZB.ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.BUSINESS_TYPE = business_type;
            _outWTB_YEWUZB.CUSTOM_TYPE = "01";
            _outWTB_YEWUZB.EMAIL = rpEntity.email;
            //_outWTB_YEWUZB.COMPANY_NAME = rpEntity.company_name;
            //_outWTB_YEWUZB.COMPANY_TYPE = rpEntity.company_type;
            _outWTB_YEWUZB.CARD_ID = rpEntity.card_id;
            _outWTB_YEWUZB.ADDRESS = rpEntity.address;
            //_outWTB_YEWUZB.BILL_ADDRESS = rpEntity.bill_address;
            _outWTB_YEWUZB.S_BEIYOGN3 = rpEntity.source;
            _outWTB_YIHUDRKXX.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YIHUDRKXX.REQ_TYPE = rpEntity.req_type;
            _outWTB_YIHUDRKXX.COMPANY = rpEntity.company;
            _outWTB_YIHUDRKXX.SETTLE_METHOD = rpEntity.settle_method;
            _outWTB_YIHUDRKXX.YWYHDZ = rpEntity.ywyhdz;
            //_outWTB_YIHUDRKXX.INCLUDE_APPLICANT = rpEntity.include_applicant;
            List<CertList> list = selectList(rpEntity.CertList, "02", "01");//是受益人且证明信息=身份证明
            _outWTB_YIHUDRKXX.PEOPLE_NUM = getPEOPLE_NUM(list).ToString();
            _outWTB_YIHUDRKXX.OPER_TYPE = rpEntity.oper_type;
            _outWTB_YIHUDRKXX.CONTACT_NUM = rpEntity.contact_num;
            _outWTB_YIHUDRKXX.ADDRESS_CHECK = rpEntity.address_check;


            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_YIHUDRKXX = _outWTB_YIHUDRKXX;
        }
        
        /// <summary>
        /// 客户信息变更
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_YIHUDRKXX"></param>
        /// <returns></returns>
        public void CreatecustomerInfoChangeEntity(customerInfoChangeEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out WTB_KEHUXX _WTB_KEHUXX, out List<WTB_LIANXIXX> _WTB_LIANXIXXs)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_KEHUXX _outWTB_KEHUXX = new WTB_KEHUXX();
            List<WTB_LIANXIXX> _outWTB_LIANXIXXs = new List<WTB_LIANXIXX>();
            string business_type = rpEntity.business_type;
            //数据表基础信息赋值
            _outWTB_YEWUZB.ID = 0;
            _outWTB_KEHUXX.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = business_type + GetTimeStamp();//此处为incident_type+ GetTimeStamp()
            _outWTB_KEHUXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
            _outWTB_YEWUZB.D_JIESHOUSJ = DateTime.Now;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;//处理中
            //_outWTB_YEWUZB.IS_TRANSFER_ORDER = rpEntity.is_transfer_order;
            //_outWTB_YEWUZB.SHW_COMPANY_SOURCE = rpEntity.shw_company_source;

            //一网通办接口字段赋值
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.INCIDENT_TYPE = "McsItemType.CustomerInfoChange";//此处为incident_type
            _outWTB_YEWUZB.CARD_ID = rpEntity.card_id;
            _outWTB_YEWUZB.BILL_ADDRESS = rpEntity.send_address;
            //_outWTB_YEWUZB.EMAIL = rpEntity.yb;


            _outWTB_YEWUZB.BUSINESS_TYPE = business_type;

            _outWTB_KEHUXX.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_KEHUXX.SOCIAL_CREDIT_CODE = rpEntity.social_credit_code;
            _outWTB_KEHUXX.SEND_ADDRESS = rpEntity.send_address;
            _outWTB_KEHUXX.RECEIVER = rpEntity.receiver;
            _outWTB_KEHUXX.YB = rpEntity.yb;
            _outWTB_KEHUXX.S_COMMENT = rpEntity.comment;
            _outWTB_KEHUXX.S_BEIYONG2 = "客户联系信息变更";//"居民/单位过户";
            _outWTB_KEHUXX.S_BEIYONG1 = rpEntity.source;
            _outWTB_KEHUXX.S_BEIYONG3 = rpEntity.reserve1 + "|" + rpEntity.reserve2 + "|" + rpEntity.reserve3;


            foreach (conList item in rpEntity.conList)
            {
                WTB_LIANXIXX _outWTB_LIANXIXX = new WTB_LIANXIXX();
                _outWTB_LIANXIXX.ID = 0;
                _outWTB_LIANXIXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
                _outWTB_LIANXIXX.INCIDENT_ID = _outWTB_YEWUZB.INCIDENT_ID;
                _outWTB_LIANXIXX.CON_NAME = item.con_name;
                _outWTB_LIANXIXX.CON_VALUE = item.con_value;
                _outWTB_LIANXIXX.EMAIL = item.email;
                _outWTB_LIANXIXXs.Add(_outWTB_LIANXIXX);
            }

            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_KEHUXX = _outWTB_KEHUXX;
            _WTB_LIANXIXXs = _outWTB_LIANXIXXs;
        }

        /// <summary>
        /// 5.13	补缴费通知单
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_FAPIAOXXs"></param>
        public void CreatepayNoticeRemailEntity(payNoticeRemailEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out List<WTB_FAPIAOXX> _WTB_FAPIAOXXs)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            List<WTB_FAPIAOXX> _outWTB_FAPIAOXXs = new List<WTB_FAPIAOXX>();

            //数据表基础信息赋值
            _outWTB_YEWUZB.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = rpEntity.business_type + GetTimeStamp();
            _outWTB_YEWUZB.D_JIESHOUSJ = DateTime.Now;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;//处理中


            //一网同步接口字段赋值
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.CON_NAME = rpEntity.applicant;
            _outWTB_YEWUZB.CONTACT_VALUE = rpEntity.contact_number;
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.INCIDENT_TYPE = "McsItemType.PayNoticeRemail";
            _outWTB_YEWUZB.BUSINESS_TYPE = rpEntity.business_type;
            _outWTB_YEWUZB.CARD_ID = rpEntity.card_id;

            foreach (var item in rpEntity.bill_month)
            {
                WTB_FAPIAOXX _WTB_FAPIAOXX = new WTB_FAPIAOXX();
                _WTB_FAPIAOXX.ID = 0;
                _WTB_FAPIAOXX.INCIDENT_ID = rpEntity.incident_id;
                _WTB_FAPIAOXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
                _WTB_FAPIAOXX.BILL_MONTH = item.bill_month;
                _WTB_FAPIAOXX.S_BEIYONG1 = rpEntity.source;
                _WTB_FAPIAOXX.S_BEIYONG2 = rpEntity.notice_type;
                _WTB_FAPIAOXX.S_BEIYONG3 = rpEntity.reserve1 + "" + rpEntity.reserve2 + "" + rpEntity.reserve3;
                _outWTB_FAPIAOXXs.Add(_WTB_FAPIAOXX);
            }
            
            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_FAPIAOXXs = _outWTB_FAPIAOXXs;
        }
        /// <summary>
        /// 5.15	电子发票自动推送
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_FAPIAOXXs"></param>
        public void CreateelecInvoiceAutoPushEntity(elecInvoiceAutoPushEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out WTB_FAPIAOXX _WTB_FAPIAOXX)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_FAPIAOXX _outWTB_FAPIAOXX = new WTB_FAPIAOXX();

            //数据表基础信息赋值
            _outWTB_YEWUZB.ID = 0;
            _outWTB_FAPIAOXX.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = rpEntity.business_type + GetTimeStamp();
            _outWTB_FAPIAOXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
            _outWTB_YEWUZB.D_JIESHOUSJ = DateTime.Now;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;//处理中
            _outWTB_YEWUZB.INCIDENT_TYPE = "McsItemType.ElecInvoiceAutoPush";
            _outWTB_YEWUZB.CERT_TYPE = rpEntity.cert_type;
            _outWTB_YEWUZB.CERT_NUMBER = rpEntity.cert_number;

            //一网同步接口字段赋值
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.SOCIAL_CREDIT_CODE = rpEntity.social_credit_code;
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.BUSINESS_TYPE = rpEntity.business_type;
            _outWTB_YEWUZB.CARD_ID = rpEntity.card_id;
            _outWTB_YEWUZB.SHW_ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.CONTACT_VALUE=rpEntity.contact_number;
            _outWTB_YEWUZB.EMAIL=rpEntity.email;


        //    /// <summary>
        /////	注册地址	/// </summary>
        //public string zcdz { get; set; }
        ///// <summary>
        /////	发票抬头	/// </summary>
        //public string fptt { get; set; }
        ///// <summary>
        /////	开户行	/// </summary>
        //public string khh { get; set; }
        ///// <summary>
        /////	银行卡号	/// </summary>
        //public string khhzh { get; set; }

            _outWTB_FAPIAOXX.INCIDENT_ID = rpEntity.incident_id;
            //_outWTB_FAPIAOXX.CONTACT_INVOICE = rpEntity.contact_invoice;
            _outWTB_FAPIAOXX.SOCIAL_CREDIT_CODE = rpEntity.social_credit_code;
            _outWTB_FAPIAOXX.APPLY_TYPE = rpEntity.apply_type;
            _outWTB_FAPIAOXX.S_BEIYONG1 = rpEntity.source;

            _outWTB_FAPIAOXX.CONTACT_INVOICE = rpEntity.contact_invoice;
            _outWTB_FAPIAOXX.POST_ADDRESS = rpEntity.zcdz;
            _outWTB_FAPIAOXX.FPTT = rpEntity.fptt; //fptt
            _outWTB_FAPIAOXX.OPEN_BANK = rpEntity.khh;//open_bank
            _outWTB_FAPIAOXX.BANK_CARD_NO = rpEntity.khhzh;//bank_card_no

            _outWTB_FAPIAOXX.S_BEIYONG3 = rpEntity.reserve1+"|"+rpEntity.reserve2+"|"+rpEntity.reserve3;
            
            
            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_FAPIAOXX = _outWTB_FAPIAOXX;
        }
        /// <summary>
        /// 5.16	电子发票单次获取
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_FAPIAOXXs"></param>
        public void CreateelecInvoiceObtainEntity(elecInvoiceObtainEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out List<WTB_FAPIAOXX> _WTB_FAPIAOXXs)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            //WTB_FAPIAOXX _outWTB_FAPIAOXX = new WTB_FAPIAOXX();
            List<WTB_FAPIAOXX> _outWTB_FAPIAOXXs = new List<WTB_FAPIAOXX>();

            //数据表基础信息赋值
            _outWTB_YEWUZB.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = rpEntity.business_type + GetTimeStamp();
            _outWTB_YEWUZB.D_JIESHOUSJ = DateTime.Now;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;//处理中
            _outWTB_YEWUZB.INCIDENT_TYPE = "McsItemType.ElecInvoiceObtain";

            //一网同步接口字段赋值
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.BUSINESS_TYPE = rpEntity.business_type;
            _outWTB_YEWUZB.CARD_ID = rpEntity.card_id;
            _outWTB_YEWUZB.SHW_ADDRESS = rpEntity.shw_address;
            _outWTB_YEWUZB.COMPANY_NAME = rpEntity.company_name;
            _outWTB_YEWUZB.CONTACT_VALUE = rpEntity.contact_number;//contact_number
            _outWTB_YEWUZB.EMAIL = rpEntity.email;//email


            foreach (var item in rpEntity.billList)
            {
                WTB_FAPIAOXX _WTB_FAPIAOXX = new WTB_FAPIAOXX();
                
                _WTB_FAPIAOXX.ID = 0;
                _WTB_FAPIAOXX.INCIDENT_ID = rpEntity.incident_id;
                _WTB_FAPIAOXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
                _WTB_FAPIAOXX.USER_NAME = rpEntity.user_name;
                _WTB_FAPIAOXX.BILL_MONTH = item.bill_month;
                _WTB_FAPIAOXX.MONEY = item.money;
                _WTB_FAPIAOXX.POST_ADDRESS = rpEntity.post_address;
                _WTB_FAPIAOXX.CONTACT_INVOICE = rpEntity.contact_invoice;
                _WTB_FAPIAOXX.COMPANY_NAME = rpEntity.company_name;//            company_name
                _WTB_FAPIAOXX.SOCIAL_CREDIT_CODE = rpEntity.nsrsbh;       //nsrsbh      
                _WTB_FAPIAOXX.FPTT = rpEntity.fptt; //fptt
                _WTB_FAPIAOXX.OPEN_BANK = rpEntity.open_bank;//open_bank
                _WTB_FAPIAOXX.BANK_CARD_NO = rpEntity.bank_card_no;//bank_card_no
                _WTB_FAPIAOXX.S_BEIYONG1 = rpEntity.source;
                _WTB_FAPIAOXX.S_BEIYONG3 = rpEntity.reserve1 + "|" + rpEntity.reserve2 + "|" + rpEntity.reserve3;

                _outWTB_FAPIAOXXs.Add(_WTB_FAPIAOXX);
            }
            


            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_FAPIAOXXs = _outWTB_FAPIAOXXs;
        }


        public void CreatemeterMoveEntity(meterMoveEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out WTB_BAOXIUXX _WTB_BAOXIUXX)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_BAOXIUXX _outWTB_BAOXIUXX = new WTB_BAOXIUXX();
            List<repairFile> _outfiles = new List<repairFile>();
            //数据表基础信息赋值
            _outWTB_YEWUZB.ID = 0;
            _outWTB_BAOXIUXX.ID = 0;
            _outWTB_YEWUZB.BUSINESS_TYPE = "29";
            _outWTB_YEWUZB.S_ZHUBIAOBH = _outWTB_YEWUZB.BUSINESS_TYPE + GetTimeStamp();
            _outWTB_BAOXIUXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
            
            _outWTB_YEWUZB.D_JIESHOUSJ = DateTime.Now;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;//处理中
            //_outWTB_YEWUZB.IS_TRANSFER_ORDER = rpEntity.is_transfer_order;
            //_outWTB_YEWUZB.SHW_COMPANY_SOURCE = rpEntity.shw_company_source;

            //一网同步接口字段赋值
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            //_outWTB_YEWUZB.CUSTOM_TYPE = rpEntity.custom_type;
            //_outWTB_YEWUZB.SHW_ADDRESS = rpEntity.shw_address;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.INCIDENT_TYPE = "McsItemType.RepairMeterOutward";
            _outWTB_YEWUZB.CERT_TYPE = rpEntity.cert_type;
            _outWTB_YEWUZB.CERT_NUMBER = rpEntity.cert_number;
            _outWTB_YEWUZB.EMAIL = rpEntity.email;
            //_outWTB_YEWUZB.COMPANY_NAME = rpEntity.company_name;
            //_outWTB_YEWUZB.COMPANY_TYPE = rpEntity.company_type;
            //_outWTB_YEWUZB.SOCIAL_CREDIT_CODE = rpEntity.social_credit_code;
            //_outWTB_BAOXIUXX.CASE_TYPE_CD = rpEntity.case_type_cd;
            _outWTB_YEWUZB.CARD_ID = rpEntity.card_id;
            //_outWTB_YEWUZB.ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.CONTACT_VALUE = rpEntity.contact_num;

            _outWTB_BAOXIUXX.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_BAOXIUXX.S_BEIYONG1 = rpEntity.source+"|"+rpEntity.bookTime;


            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_BAOXIUXX = _outWTB_BAOXIUXX;
        }

        /// <summary>
        /// 新表启封
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_SHOULIXX"></param>
        public void CreatemeterUnsealEntity(meterUnsealEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out WTB_SHOULIXX _WTB_SHOULIXX)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_SHOULIXX _outWTB_SHOULIXX = new WTB_SHOULIXX();
            List<repairFile> _outfiles = new List<repairFile>();
            string _BUSINESS_TYPE = "30";


            _outWTB_YEWUZB.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = _BUSINESS_TYPE + GetTimeStamp(); ;
            _outWTB_YEWUZB.CUSTOM_TYPE = "";
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.CONTACT_VALUE = rpEntity.contact_num;
            _outWTB_YEWUZB.CARD_ID = ""; ;
            _outWTB_YEWUZB.APPLY_CONTENT = "";
            _outWTB_YEWUZB.COMPANY_NAME = "";
            _outWTB_YEWUZB.COMPANY_TYPE = "";
            _outWTB_YEWUZB.SOCIAL_CREDIT_CODE = "";
            _outWTB_YEWUZB.PHONE = "";
            _outWTB_YEWUZB.WYGZ = "";
            _outWTB_YEWUZB.BUSINESS_TYPE = _BUSINESS_TYPE;
            _outWTB_YEWUZB.SHW_ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.INCIDENT_TYPE = "McsItemType.RepairUnseal";
            _outWTB_YEWUZB.CERT_TYPE = rpEntity.cert_type;
            _outWTB_YEWUZB.MAIL = "";
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.CERT_NUMBER = rpEntity.cert_number;
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.EMAIL = rpEntity.email;
            _outWTB_YEWUZB.ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.CON_NAME = rpEntity.applicant;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            //_outWTB_YEWUZB.I_BEIYONG1=DBNull.Value;
            //_outWTB_YEWUZB.I_BEIYONG2=DBNull.Value;
            //_outWTB_YEWUZB.S_BEIYOGN1=DBNull.Value;
            //_outWTB_YEWUZB.S_BEIYOGN2=DBNull.Value;
            //_outWTB_YEWUZB.S_BEIYOGN3=DBNull.Value;
            _outWTB_YEWUZB.D_JIESHOUSJ=DateTime.Now;
            //_outWTB_YEWUZB.D_HUITIANSJ=DBNull.Value;
            //_outWTB_YEWUZB.D_BEIYOGN3=DBNull.Value;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;
            _outWTB_YEWUZB.IS_TRANSFER_ORDER = "0";
            _outWTB_YEWUZB.SHW_COMPANY_SOURCE = "";
            _outWTB_YEWUZB.BILL_ADDRESS = "";


            _outWTB_SHOULIXX.ID = 0;
            _outWTB_SHOULIXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
            _outWTB_SHOULIXX.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_SHOULIXX.CONTACT_NUM = rpEntity.contact_num;
            _outWTB_SHOULIXX.SOURCE = rpEntity.source;
            _outWTB_SHOULIXX.BDCZL = rpEntity.bdczl;
            _outWTB_SHOULIXX.FCZJHM = rpEntity.fczjhm;
            _outWTB_SHOULIXX.BDCDBRQ = rpEntity.bdcdbrq;
            //_outWTB_SHOULIXX.NSRSBH = rpEntity.;
            _outWTB_SHOULIXX.FCZJLX = rpEntity.fczjlx;
            _outWTB_SHOULIXX.BOOKTIME = rpEntity.bookTime;
            //_outWTB_SHOULIXX.WATERTYPE = rpEntity.;
            //_outWTB_SHOULIXX.REASON = rpEntity.;
            _outWTB_SHOULIXX.COMPANY_ID = rpEntity.company_id;
            //_outWTB_SHOULIXX.S_BEIYONG1 = rpEntity;
            //_outWTB_SHOULIXX.S_BEIYONG2 = rpEntity;
            //_outWTB_SHOULIXX.S_BEIYONG3 = rpEntity;
            //_outWTB_SHOULIXX.S_BEIYONG4 = rpEntity;
            //_outWTB_SHOULIXX.S_BEIYONG5 = rpEntity;
            //_outWTB_SHOULIXX.S_BEIYONG6 = rpEntity;




            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_SHOULIXX = _outWTB_SHOULIXX;
        }
        /// <summary>
        /// 水表拆除销户
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_SHOULIXX"></param>
        public void CreateaccountCancelEntity(accountCancelEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out WTB_SHOULIXX _WTB_SHOULIXX)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_SHOULIXX _outWTB_SHOULIXX = new WTB_SHOULIXX();
            List<repairFile> _outfiles = new List<repairFile>();
            string _BUSINESS_TYPE = "31";


            _outWTB_YEWUZB.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = _BUSINESS_TYPE + GetTimeStamp(); ;
            //_outWTB_YEWUZB.CUSTOM_TYPE = rpEntity;
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.CONTACT_VALUE = rpEntity.contact_num;
            _outWTB_YEWUZB.CARD_ID = rpEntity.card_id; ;
            //_outWTB_YEWUZB.APPLY_CONTENT = rpEntity.;
            _outWTB_YEWUZB.COMPANY_NAME = rpEntity.company_name;
            _outWTB_YEWUZB.COMPANY_TYPE = rpEntity.company_type;
            //_outWTB_YEWUZB.SOCIAL_CREDIT_CODE = rpEntity.;
            //_outWTB_YEWUZB.PHONE = rpEntity.;
            //_outWTB_YEWUZB.WYGZ = rpEntity.;
            _outWTB_YEWUZB.BUSINESS_TYPE = _BUSINESS_TYPE;
            _outWTB_YEWUZB.SHW_ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.INCIDENT_TYPE = "McsItemType.WriteOffAccount";
            _outWTB_YEWUZB.CERT_TYPE = rpEntity.cert_type;
            //_outWTB_YEWUZB.MAIL = rpEntity."";
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.CERT_NUMBER = rpEntity.cert_number;
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.EMAIL = rpEntity.email;
            _outWTB_YEWUZB.ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.CON_NAME = rpEntity.applicant;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            //_outWTB_YEWUZB.I_BEIYONG1=DBNull.Value;
            //_outWTB_YEWUZB.I_BEIYONG2=DBNull.Value;
            //_outWTB_YEWUZB.S_BEIYOGN1=DBNull.Value;
            //_outWTB_YEWUZB.S_BEIYOGN2=DBNull.Value;
            //_outWTB_YEWUZB.S_BEIYOGN3=DBNull.Value;
            _outWTB_YEWUZB.D_JIESHOUSJ=DateTime.Now;
            //_outWTB_YEWUZB.D_HUITIANSJ=DBNull.Value;
            //_outWTB_YEWUZB.D_BEIYOGN3=DBNull.Value;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;
            _outWTB_YEWUZB.IS_TRANSFER_ORDER = "0";
            _outWTB_YEWUZB.SHW_COMPANY_SOURCE = "";
            _outWTB_YEWUZB.BILL_ADDRESS = "";


            _outWTB_SHOULIXX.ID = 0;
            _outWTB_SHOULIXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
            _outWTB_SHOULIXX.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_SHOULIXX.CONTACT_NUM = rpEntity.contact_num;
            _outWTB_SHOULIXX.SOURCE = rpEntity.source;
            _outWTB_SHOULIXX.BDCZL = rpEntity.bdczl;
            _outWTB_SHOULIXX.FCZJHM = rpEntity.fczjhm;
            _outWTB_SHOULIXX.BDCDBRQ = rpEntity.bdcdbrq;
            _outWTB_SHOULIXX.NSRSBH = rpEntity.nsrsbh;
            _outWTB_SHOULIXX.FCZJLX = rpEntity.fczjlx;
            //_outWTB_SHOULIXX.BOOKTIME = rpEntity.;
            //_outWTB_SHOULIXX.WATERTYPE = rpEntity.;
            _outWTB_SHOULIXX.REASON = rpEntity.reason;


            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_SHOULIXX = _outWTB_SHOULIXX;
        }
        /// <summary>
        /// 合用表
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_HEYONGBXX"></param>
        public void CreateshareMeterEntity(shareMeterEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out WTB_HEYONGBXX _WTB_HEYONGBXX)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_HEYONGBXX _outWTB_HEYONGBXX = new WTB_HEYONGBXX();
            List<repairFile> _outfiles = new List<repairFile>();
            string _BUSINESS_TYPE = "32";


            _outWTB_YEWUZB.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = _BUSINESS_TYPE + GetTimeStamp(); ;
            //_outWTB_YEWUZB.CUSTOM_TYPE = rpEntity.;
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.CONTACT_VALUE = rpEntity.contact_num;
            _outWTB_YEWUZB.CARD_ID = rpEntity.card_id; ;
            //_outWTB_YEWUZB.APPLY_CONTENT = rpEntity.app;
            //_outWTB_YEWUZB.COMPANY_NAME = rpEntity.;
            //_outWTB_YEWUZB.COMPANY_TYPE = rpEntity.;
            //_outWTB_YEWUZB.SOCIAL_CREDIT_CODE = rpEntity.;
            //_outWTB_YEWUZB.PHONE = rpEntity.;
            //_outWTB_YEWUZB.WYGZ = rpEntity.;
            _outWTB_YEWUZB.BUSINESS_TYPE = _BUSINESS_TYPE;
            _outWTB_YEWUZB.SHW_ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.INCIDENT_TYPE = "McsItemType.SharingWaterMeter";
            _outWTB_YEWUZB.CERT_TYPE = rpEntity.cert_type;
            //_outWTB_YEWUZB.MAIL = rpEntity.;
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.CERT_NUMBER = rpEntity.cert_number;
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.EMAIL = rpEntity.email;
            _outWTB_YEWUZB.ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.CON_NAME = rpEntity.applicant;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            //_outWTB_YEWUZB.I_BEIYONG1=DBNull.Value;
            //_outWTB_YEWUZB.I_BEIYONG2=DBNull.Value;
            //_outWTB_YEWUZB.S_BEIYOGN1=DBNull.Value;
            //_outWTB_YEWUZB.S_BEIYOGN2=DBNull.Value;
            //_outWTB_YEWUZB.S_BEIYOGN3=DBNull.Value;
            _outWTB_YEWUZB.D_JIESHOUSJ = DateTime.Now;
            //_outWTB_YEWUZB.D_HUITIANSJ=DBNull.Value;
            //_outWTB_YEWUZB.D_BEIYOGN3=DBNull.Value;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;


            _outWTB_HEYONGBXX.ID = 0;
            _outWTB_HEYONGBXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
            _outWTB_HEYONGBXX.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_HEYONGBXX.SOURCE = rpEntity.source;
            _outWTB_HEYONGBXX.APP_TYPE = rpEntity.app_type;
            _outWTB_HEYONGBXX.CONTACT_NUM = rpEntity.contact_num;
            _outWTB_HEYONGBXX.REQ_TYPE = rpEntity.req_type;
            _outWTB_HEYONGBXX.COMPANY = rpEntity.company;
            _outWTB_HEYONGBXX.BOOKLETNUM = rpEntity.bookletNum;

            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_HEYONGBXX = _outWTB_HEYONGBXX;
        }

        /// <summary>
        /// 水费托收
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_SHOULIXX"></param>
        public void CreatechargeCollectionEntity(chargeCollectionEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out WTB_SHOULIXX _WTB_SHOULIXX)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_SHOULIXX _outWTB_SHOULIXX = new WTB_SHOULIXX();
            List<repairFile> _outfiles = new List<repairFile>();
            string _BUSINESS_TYPE = "33";


            _outWTB_YEWUZB.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = _BUSINESS_TYPE + GetTimeStamp(); ;
            //_outWTB_YEWUZB.CUSTOM_TYPE = rpEntity;
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.CONTACT_VALUE = rpEntity.contact_num;
            _outWTB_YEWUZB.CARD_ID = rpEntity.card_id; ;
            //_outWTB_YEWUZB.APPLY_CONTENT = rpEntity.;
            _outWTB_YEWUZB.COMPANY_NAME = rpEntity.company_name;
            _outWTB_YEWUZB.COMPANY_TYPE = rpEntity.company_type;
            //_outWTB_YEWUZB.SOCIAL_CREDIT_CODE = rpEntity.;
            //_outWTB_YEWUZB.PHONE = rpEntity.;
            //_outWTB_YEWUZB.WYGZ = rpEntity.;
            _outWTB_YEWUZB.BUSINESS_TYPE = _BUSINESS_TYPE;
            _outWTB_YEWUZB.SHW_ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.INCIDENT_TYPE = "McsItemType.WaterRateCollection";
            _outWTB_YEWUZB.CERT_TYPE = rpEntity.cert_type;
            //_outWTB_YEWUZB.MAIL = rpEntity.;
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.CERT_NUMBER = rpEntity.cert_number;
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.EMAIL = rpEntity.email;
            _outWTB_YEWUZB.ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.CON_NAME = rpEntity.applicant;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            //_outWTB_YEWUZB.I_BEIYONG1=DBNull.Value;
            //_outWTB_YEWUZB.I_BEIYONG2=DBNull.Value;
            //_outWTB_YEWUZB.S_BEIYOGN1=DBNull.Value;
            //_outWTB_YEWUZB.S_BEIYOGN2=DBNull.Value;
            //_outWTB_YEWUZB.S_BEIYOGN3=DBNull.Value;
            _outWTB_YEWUZB.D_JIESHOUSJ = DateTime.Now;
            //_outWTB_YEWUZB.D_HUITIANSJ=DBNull.Value;
            //_outWTB_YEWUZB.D_BEIYOGN3=DBNull.Value;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;
            //_outWTB_YEWUZB.IS_TRANSFER_ORDER = rpEntity.;
            //_outWTB_YEWUZB.SHW_COMPANY_SOURCE = "";
            //_outWTB_YEWUZB.BILL_ADDRESS = "";


            _outWTB_SHOULIXX.ID = 0;
            _outWTB_SHOULIXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
            _outWTB_SHOULIXX.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_SHOULIXX.CONTACT_NUM = rpEntity.contact_num;
            _outWTB_SHOULIXX.SOURCE = rpEntity.source;
            //_outWTB_SHOULIXX.BDCZL = rpEntity.bdczl;
            //_outWTB_SHOULIXX.FCZJHM = rpEntity.fczjhm;
            //_outWTB_SHOULIXX.BDCDBRQ = rpEntity.bdcdbrq;
            _outWTB_SHOULIXX.NSRSBH = rpEntity.nsrsbh;
            //_outWTB_SHOULIXX.FCZJLX = rpEntity.fczjlx;
            _outWTB_SHOULIXX.S_BEIYONG1 = rpEntity.bank_account + "|" + rpEntity.account_name + "|" + rpEntity.bank;//rpEntity.head_bank + "|" + rpEntity.brank_bank;
           

            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_SHOULIXX = _outWTB_SHOULIXX;
        }

        /// <summary>
        /// 用水性质变更
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_SHOULIXX"></param>
        public void CreatewaterTypeChangeEntity(waterTypeChangeEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out WTB_SHOULIXX _WTB_SHOULIXX)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_SHOULIXX _outWTB_SHOULIXX = new WTB_SHOULIXX();
            List<repairFile> _outfiles = new List<repairFile>();
            string _BUSINESS_TYPE = "34";


            _outWTB_YEWUZB.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = _BUSINESS_TYPE + GetTimeStamp(); ;
            //_outWTB_YEWUZB.CUSTOM_TYPE = rpEntity.;
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.CONTACT_VALUE = rpEntity.contact_num;
            _outWTB_YEWUZB.CARD_ID = rpEntity.card_id; ;
            //_outWTB_YEWUZB.APPLY_CONTENT = rpEntity.;
            _outWTB_YEWUZB.COMPANY_NAME = rpEntity.company_name;
            //_outWTB_YEWUZB.COMPANY_TYPE = rpEntity.company_type; 4.8接口文档取消此字段
            //_outWTB_YEWUZB.SOCIAL_CREDIT_CODE = rpEntity.;
            //_outWTB_YEWUZB.PHONE = rpEntity.;
            //_outWTB_YEWUZB.WYGZ = rpEntity.;
            _outWTB_YEWUZB.BUSINESS_TYPE = _BUSINESS_TYPE;
            _outWTB_YEWUZB.SHW_ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.INCIDENT_TYPE = "McsItemType.UseWaterNatureChange";
            _outWTB_YEWUZB.CERT_TYPE = rpEntity.cert_type;
            //_outWTB_YEWUZB.MAIL = rpEntity.;
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.CERT_NUMBER = rpEntity.cert_number;
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.EMAIL = rpEntity.email;
            _outWTB_YEWUZB.ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.CON_NAME = rpEntity.applicant;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            //_outWTB_YEWUZB.I_BEIYONG1=DBNull.Value;
            //_outWTB_YEWUZB.I_BEIYONG2=DBNull.Value;
            //_outWTB_YEWUZB.S_BEIYOGN1=DBNull.Value;
            //_outWTB_YEWUZB.S_BEIYOGN2=DBNull.Value;
            //_outWTB_YEWUZB.S_BEIYOGN3=DBNull.Value;
            _outWTB_YEWUZB.D_JIESHOUSJ = DateTime.Now;
            //_outWTB_YEWUZB.D_HUITIANSJ=DBNull.Value;
            //_outWTB_YEWUZB.D_BEIYOGN3=DBNull.Value;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;
            //_outWTB_YEWUZB.IS_TRANSFER_ORDER = rpEntity.;
            //_outWTB_YEWUZB.SHW_COMPANY_SOURCE = "";
            _outWTB_YEWUZB.BILL_ADDRESS = "";


            _outWTB_SHOULIXX.ID = 0;
            _outWTB_SHOULIXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
            _outWTB_SHOULIXX.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_SHOULIXX.CONTACT_NUM = rpEntity.contact_num;
            _outWTB_SHOULIXX.SOURCE = rpEntity.source;
            //_outWTB_SHOULIXX.BDCZL = rpEntity.bdczl;
            //_outWTB_SHOULIXX.FCZJHM = rpEntity.fczjhm;
            //_outWTB_SHOULIXX.BDCDBRQ = rpEntity.bdcdbrq;
            _outWTB_SHOULIXX.NSRSBH = rpEntity.nsrsbh;
            //_outWTB_SHOULIXX.FCZJLX = rpEntity.fczjlx;
            //_outWTB_SHOULIXX.BOOKTIME = rpEntity.bo;
            _outWTB_SHOULIXX.WATERTYPE = rpEntity.waterType;



            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_SHOULIXX = _outWTB_SHOULIXX;
        }

        /// <summary>
        /// 业务咨询表扬建议
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="_WTB_YEWUZB"></param>
        /// <param name="_WTB_BAOXIUXX"></param>
        public void CreateadviceComplainEntity(adviceComplainEntity rpEntity, out WTB_YEWUZB _WTB_YEWUZB, out WTB_BAOXIUXX _WTB_BAOXIUXX)
        {
            WTB_YEWUZB _outWTB_YEWUZB = new WTB_YEWUZB();
            WTB_BAOXIUXX _outWTB_BAOXIUXX = new WTB_BAOXIUXX();
            List<repairFile> _outfiles = new List<repairFile>();
            string _BUSINESS_TYPE = "35";
            //
            //数据表基础信息赋值
            _outWTB_YEWUZB.ID = 0;
            _outWTB_BAOXIUXX.ID = 0;
            _outWTB_YEWUZB.S_ZHUBIAOBH = _BUSINESS_TYPE + GetTimeStamp();
            _outWTB_BAOXIUXX.S_ZHUBIAOBH = _outWTB_YEWUZB.S_ZHUBIAOBH;
            _outWTB_YEWUZB.BUSINESS_TYPE = _BUSINESS_TYPE;
            _outWTB_YEWUZB.D_JIESHOUSJ = DateTime.Now;
            _outWTB_YEWUZB.D_CAOZUOSJ = DateTime.Now;
            _outWTB_YEWUZB.I_ZHUANGTAI = 1;//处理中


            //一网同步接口字段赋值
            _outWTB_YEWUZB.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_YEWUZB.APPLY_NO = rpEntity.apply_no;
            _outWTB_YEWUZB.CUSTOM_TYPE = rpEntity.custom_type;
            _outWTB_YEWUZB.SHW_ADDRESS = rpEntity.shw_address;
            _outWTB_YEWUZB.APPLICANT = rpEntity.applicant;
            _outWTB_YEWUZB.APPDATE = rpEntity.appdate;
            _outWTB_YEWUZB.INCIDENT_TYPE = rpEntity.incident_type;
            _outWTB_YEWUZB.CERT_TYPE = rpEntity.cert_type;
            _outWTB_YEWUZB.CERT_NUMBER = rpEntity.cert_number;
            _outWTB_YEWUZB.EMAIL = rpEntity.email;
            _outWTB_YEWUZB.COMPANY_NAME = rpEntity.company_name;
            _outWTB_YEWUZB.COMPANY_TYPE = rpEntity.company_type;
            _outWTB_YEWUZB.SOCIAL_CREDIT_CODE = rpEntity.social_credit_code;
            _outWTB_BAOXIUXX.CASE_TYPE_CD = rpEntity.case_type_cd;
            _outWTB_YEWUZB.CARD_ID = rpEntity.card_id;
            _outWTB_YEWUZB.ADDRESS = rpEntity.address;
            _outWTB_YEWUZB.CONTACT_VALUE = rpEntity.contact_value;


            _outWTB_BAOXIUXX.INCIDENT_ID = rpEntity.incident_id;
            _outWTB_BAOXIUXX.S_BEIYONG1 = rpEntity.source+"|";
            _outWTB_BAOXIUXX.FYLY = rpEntity.fyly;
            _outWTB_BAOXIUXX.FYXS = rpEntity.fyxs;
            _outWTB_BAOXIUXX.FYQM = rpEntity.fyqm;
            _outWTB_BAOXIUXX.FYLB = rpEntity.fylb;
            _outWTB_BAOXIUXX.FYNR = rpEntity.fynr;
            _outWTB_BAOXIUXX.BX_DTTM = rpEntity.fy_dttm;


            _WTB_YEWUZB = _outWTB_YEWUZB;
            _WTB_BAOXIUXX = _outWTB_BAOXIUXX;
        }
        #endregion


        public ResultEntity VALIDATEYEWU(string card_id, string businessType, string extends)
        {
            ResultEntity _ResultEntity = new ResultEntity();//业务校验结果entity
            string body = "";
            _ResultEntity.card_id = card_id;
            _ResultEntity.isSuccess = false;
            _ResultEntity.code = 200;//HTTP状态码

            LogUtil.Info("VALIDATEYEWU接收业务办理时求值：card_id:" + card_id + ";businessType:" + businessType + ";extends:" + extends);

            try
            {
                DataTable dt = new AccessDataBase().GetParamsDataSource("<PROCEDURE>", "SELECT;WTB_VALIDATEYEWUXX;" + card_id + ";" + businessType +";"+ extends, "").Tables[0];//searchWaterUserInfo(card_id, businessType, queryType, null);
                if (dt != null && dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["ErrorInfo"].ToString().Split('|')[0] == "00")
                    {
                        _ResultEntity.isSuccess = true;
                        goto last;
                    }
                    else
                    {
                        _ResultEntity.isSuccess = false;
                        _ResultEntity.code = 500;
                        _ResultEntity.errCode = dt.Rows[0]["ErrorInfo"].ToString().Split('|')[0];
                        _ResultEntity.message = dt.Rows[0]["ErrorInfo"].ToString().Split('|')[1];
                        goto last;
                    }
                }
                else
                {
                    _ResultEntity.code = 500;
                    _ResultEntity.errCode = "07";
                    _ResultEntity.message = "参数值错误";
                    goto last;
                }
            }
            catch (Exception ex)
            {
                _ResultEntity.code = 500;
                _ResultEntity.errCode = "13";
                _ResultEntity.message = "数据库连接失败";
                LogUtil.Info(ex.Message.ToString());
                goto last;
            }
            finally
            {
                //记日志
                string s_message = _ResultEntity.message;
            }
        last:
            body = JsonConvert.SerializeObject(_ResultEntity);
        LogUtil.Info("VALIDATEYEWU方法返回结果：" + body);
            return _ResultEntity;
        }

        /// <summary>
        /// 写入子表数据
        /// </summary>
        /// <param name="rpEntity"></param>
        /// <param name="i_WsNo"></param>
        /// <returns></returns>
        public bool IsChildInsGoodByResult(object rpEntity, string s_yewulx, List<object> rpEntity1=null)
        {
            int i_Rtn_Result = 0;
            switch (s_yewulx)
            {
                case "04":
                case "05":
                case "06":
                case "07":
                case "08":
                case "09":
                case "10":
                case "11":
                case "12":
                case "13":
                case "29":
                case "35":
                    #region 报修 、 水表外移、业务咨询表扬投诉建议
                    WTB_BAOXIUXX bxEntity = (WTB_BAOXIUXX)rpEntity;
                    #endregion
                    i_Rtn_Result = new AccessDataBase().InsertWTB_BAOXIUXX(bxEntity, null);
                    break;
                case "02"://单位接水
                case "01"://居民住宅单独接水
                    #region 单位接水&居民住宅单独接水
                    WTB_JIESHUIXX jsxxEntity = (WTB_JIESHUIXX)rpEntity;
                    #endregion
                    i_Rtn_Result = new AccessDataBase().InsertWTB_JIESHUIXX(jsxxEntity, null);
                    break;
                case "14"://居民过户
                case "15"://单位过户
                case "17"://实名制
                case "18"://实名制
                case "26"://居民联合过户
                    #region 居民过户/单位过户、实名制
                    WTB_GUOHUXX ghEntity = (WTB_GUOHUXX)rpEntity;
                    i_Rtn_Result = new AccessDataBase().InsertWTB_GUOHUXX(ghEntity, null);
                    #endregion
                    break;
                case "16":
                    #region 居民住宅总表分装
                    WTB_JUMINZGFXX zgfEntity = (WTB_JUMINZGFXX)rpEntity;
                    i_Rtn_Result = new AccessDataBase().InsertWTB_JUMINZGFXX(zgfEntity, null);
                    #endregion
                    break;
                case "25":
                #region 一户多人口
                    WTB_YIHUDRKXX drkEntity = (WTB_YIHUDRKXX)rpEntity;
                    i_Rtn_Result = new AccessDataBase().InsertWTB_YIHUDRKXX(drkEntity, null);
                #endregion
                    break;
                case "19":
                case "20":
                    #region 客户联系信息变更
                    WTB_KEHUXX _Entity = (WTB_KEHUXX)rpEntity;
                    List<WTB_LIANXIXX> _lxrEntitys=new List<WTB_LIANXIXX>();
                    foreach (var item in rpEntity1)
                    {
                        WTB_LIANXIXX _Entity1 = (WTB_LIANXIXX)item;
                        _lxrEntitys.Add(_Entity1);
                    }

                    i_Rtn_Result = new AccessDataBase().InsertWTB_KEHUXX(_Entity, _lxrEntitys, null);
                    #endregion
                    break;
                case "21":
                case "22":
                case "23":
                case "24":
                    #region 补寄缴费通知单

                    List<WTB_FAPIAOXX> _Entitys21 = new List<WTB_FAPIAOXX>();
                    foreach (var item in rpEntity1)
                    {
                        WTB_FAPIAOXX _Entity1 = (WTB_FAPIAOXX)item;
                        _Entitys21.Add(_Entity1);
                    }
                    foreach (WTB_FAPIAOXX item in _Entitys21)
                    {
                        i_Rtn_Result=new AccessDataBase().InsertWTB_FAPIAOXX(item, null);
                        if (i_Rtn_Result != 1)
                        {
                            i_Rtn_Result = 0;
                            break;
                        }
                    }
                    #endregion
                    break;
                case "27":
                case "28":
                
                    #region 5.15	电子发票自动推送 及单次获取
                    WTB_FAPIAOXX _Entity29 = (WTB_FAPIAOXX)rpEntity;
                    i_Rtn_Result = new AccessDataBase().InsertWTB_FAPIAOXX(_Entity29, null);
                    if (i_Rtn_Result != 1)
                    {
                        i_Rtn_Result = 0;
                        break;
                    }
                    #endregion
                    break;
                case "30":
                case "31":
                case "33":
                case "34":
                    #region 新表启封、表拆表销户、水费托收、用水性质变更
                    WTB_SHOULIXX _Entity30 = (WTB_SHOULIXX)rpEntity;
                    i_Rtn_Result = new AccessDataBase().InsertWTB_SHOULIXX(_Entity30, null);
                    if (i_Rtn_Result != 1)
                    {
                        i_Rtn_Result = 0;
                        break;
                    }
                    #endregion
                    break;
                case "32":
                    #region 居民合用表
                    WTB_HEYONGBXX _Entity32 = (WTB_HEYONGBXX)rpEntity;
                    i_Rtn_Result = new AccessDataBase().InsertWTB_HEYONGBXX(_Entity32, null);
                    if (i_Rtn_Result != 1)
                    {
                        i_Rtn_Result = 0;
                        break;
                    }
                    #endregion
                    break;
            }
            return i_Rtn_Result > 0 ? true : false;
        }
        /// <summary>
        /// 定义返回响应结果的方法
        /// </summary>
        /// <param name="require">RequireParaEntity对象</param>
        /// <param name="intCode">状态码</param>
        /// <param name="strMsg">返回消息</param>
        /// <param name="i_WsNo">接口名称</param>
        /// <returns>XiangYingEntity对象</returns>
        public XiangYingEntity GetXiangYingResult(int intCode, string strMsg)
        {
            XiangYingEntity xyEntity = new XiangYingEntity();
            xyEntity.code = intCode;
            switch (intCode)
            {
                case 200:
                    xyEntity.isSuccess = true;
                    xyEntity.code = intCode;
                    xyEntity.message = strMsg;
                    break;
                default:
                    xyEntity.isSuccess = false;
                    xyEntity.code = 500;
                    xyEntity.errCode = intCode.ToString().PadLeft(2, '0');
                    xyEntity.message = strMsg;
                    break;
            }

            return xyEntity;
        }

        /// <summary>
        /// 定义返回响应结果的方法
        /// </summary>
        /// <param name="require">RequireParaEntity对象</param>
        /// <param name="intCode">状态码</param>
        /// <param name="strMsg">返回消息</param>
        /// <param name="i_WsNo">接口名称</param>
        /// <returns>XiangYingEntity对象</returns>
        public YHDRK_XiangYingEntity GetYHDRK_XiangYingResult(string card_id, string businessType, string incident_id, string apply_no, int intCode, string strMsg)
        {
            YHDRK_XiangYingEntity xyEntity = new YHDRK_XiangYingEntity();
            errDataEntity_New _ErrDataEntity = new errDataEntity_New();
            xyEntity.code = intCode;
            switch (intCode)
            {
                case 200:
                    xyEntity.isSuccess = true;
                    xyEntity.code = intCode;
                    xyEntity.message = strMsg;
                    break;
                default:
                    xyEntity.isSuccess = false;
                    xyEntity.code = 500;
                    xyEntity.errCode = intCode.ToString().PadLeft(2, '0');
                    xyEntity.message = strMsg;
                    break;
            }
            _ErrDataEntity.businessType = "";
            _ErrDataEntity.applyNo = "";
            _ErrDataEntity.lastApplyTime = "";
            _ErrDataEntity.source = "";

            if (intCode == 2)
            {

                DataTable dt = new AccessDataBase().GetParamsDataSource("<PROCEDURE>", "SELECT;WTB_searchWWJYWInfo;" + card_id + ";" + businessType, "").Tables[0];//searchWaterUserInfo(card_id, businessType, queryType, null);
                if (dt != null && dt.Rows.Count > 0)
                {
                    _ErrDataEntity.businessType = dt.Rows[0]["msg"].ToString();
                }

            }
            if (intCode == 9 || intCode == 15 || intCode == 16)
            {
                //返回渠道和上次申请时间
                DataTable dt = new AccessDataBase().GetParamsDataSource("<PROCEDURE>", "SELECT;WTB_searchQuDaoInfo;" + card_id + ";" + businessType + ";" + incident_id + ";" + apply_no + ";" + intCode.ToString().PadLeft(2, '0'), "").Tables[0];//searchWaterUserInfo(card_id, businessType, queryType, null);
                if (dt != null && dt.Rows.Count > 0)
                {
                    _ErrDataEntity.applyNo = dt.Rows[0]["applyNo"].ToString();
                    _ErrDataEntity.source = dt.Rows[0]["source"].ToString();
                    _ErrDataEntity.lastApplyTime = dt.Rows[0]["lastApplyTime"].ToString();
                }


            }
            xyEntity.errData = _ErrDataEntity;
            return xyEntity;
        }

        /// <summary>
        /// 验证是否能转换成decimal
        /// </summary>
        /// <param name="paraValue"></param>
        /// <returns></returns>
        public bool IsDecimal(string paraValue)
        {
            decimal _outDecimal = 0;
            return decimal.TryParse(paraValue, out _outDecimal);
        }

        #region 验证证件列表
        public bool ValidateCertList(List<CertList> list, out string s_result)
        {
            bool isGood = true;
            s_result = string.Empty;
            if (list != null && list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if (string.IsNullOrEmpty(list[i].cert_source))
                    {
                        isGood = false;
                        s_result = string.Format("第{0}个文件 证件来源不能为空", i + 1);
                        break;
                    }
                    if (isGood && string.IsNullOrEmpty(list[i].cert_type))
                    {
                        isGood = false;
                        s_result = string.Format("第{0}个文件 证件类型不能为空", i + 1);
                        break;
                    }
                    if (isGood && string.IsNullOrEmpty(list[i].cert_number))
                    {
                        isGood = false;
                        s_result = string.Format("第{0}个文件 证件号码不能为空", i + 1);
                        break;
                    }
                    if (isGood && string.IsNullOrEmpty(list[i].file_uuid))
                    {
                        isGood = false;
                        s_result = string.Format("第{0}个文件 证照UUID不能为空", i + 1);
                        break;
                    }
                    if (isGood && string.IsNullOrEmpty(list[i].filename))
                    {
                        isGood = false;
                        s_result = string.Format("第{0}个文件 文件名不能为空", i + 1);
                        break;
                    }
                }
            }
            return isGood;
        }
        public bool ValidateCertList(List<CertList> list,string leixing, out string s_result)
        {
            bool isGood = true;
            s_result = string.Empty;
            if (list != null && list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if (leixing == "01")//需判断证件人员信息
                    {
                        if (string.IsNullOrEmpty(list[i].app_type))
                        {
                            isGood = false;
                            s_result = string.Format("第{0}个文件 人员类型不能为空", i + 1);
                            break;
                        }
                        if (string.IsNullOrEmpty(list[i].name))
                        {
                            isGood = false;
                            s_result = string.Format("第{0}个文件 人员名称不能为空", i + 1);
                            break;
                        }
                        if (string.IsNullOrEmpty(list[i].bus_type))
                        {
                            isGood = false;
                            s_result = string.Format("第{0}个文件 证明类型不能为空", i + 1);
                            break;
                        }
                       
                    }
                    if (string.IsNullOrEmpty(list[i].cert_source))
                    {
                        isGood = false;
                        s_result = string.Format("第{0}个文件 证件来源不能为空", i + 1);
                        break;
                    }
                    if (isGood && string.IsNullOrEmpty(list[i].cert_type))
                    {
                        isGood = false;
                        s_result = string.Format("第{0}个文件 证件类型不能为空", i + 1);
                        break;
                    }
                    if (isGood && string.IsNullOrEmpty(list[i].cert_number))
                    {
                        isGood = false;
                        s_result = string.Format("第{0}个文件 证件号码不能为空", i + 1);
                        break;
                    }
                    if (isGood && string.IsNullOrEmpty(list[i].file_uuid))
                    {
                        isGood = false;
                        s_result = string.Format("第{0}个文件 证照UUID不能为空", i + 1);
                        break;
                    }
                    if (isGood && string.IsNullOrEmpty(list[i].filename))
                    {
                        isGood = false;
                        s_result = string.Format("第{0}个文件 文件名不能为空", i + 1);
                        break;
                    }
                }
            }
            return isGood;
        }
        
        /// <summary>
        /// 获取指定类型的人员身份列表
        /// </summary>
        /// <param name="list"></param>
        /// <param name="app_type">01：申请人；02：受益人；</param>
        /// <returns></returns>
        public List<CertList> selectList(List<CertList> list, string app_type, string bus_type)
        {
            
            return list.FindAll(delegate(CertList info)
            {
                if (info.app_type == app_type && info.bus_type == bus_type)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            });
        }

        public int getPEOPLE_NUM(List<CertList> list)
        {
            return list.GroupBy(x => new { x.name }).Select(x => x.OrderBy(y => y.name).Last()).Count();
        }
        
        #endregion

        /// <summary>
        /// 判断写入证件列表记录是否成功
        /// 1.从网通办下载文件到本地临时文件夹，然后上传到CSMS的FTP服务器上
        /// 2.将文件信息记录在列表中
        /// </summary>
        /// <returns></returns>
        public bool IsInsertCertListGood(List<CertList> paraCertList, WTB_YEWUZB WTB_YEWUZB)
        {
           
            //定义写 入证件列表 记录条数的方法
            int i_Rtn_Count = 0;
            //网通办FTP地址
            FtpWeb _ftp_wtb = null;
            FtpWeb _ftp_csms = null;
            string Environment = ConfigurationManager.AppSettings["Environment"];
            if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["FTP_IP"]))
                _ftp_wtb = new FtpWeb(ConfigurationManager.AppSettings["FTP_IP"], ConfigurationManager.AppSettings["FTP_PATH"], ConfigurationManager.AppSettings["FTP_ACCOUNT"], ConfigurationManager.AppSettings["FTP_PWD"]);
            //CSMS FTP地址
            if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["FTP_IP"]))
            {
                DataSet ds = Platform.Data.OracleHelper.ExecuteDataset(Platform.Configuration.ConfigHelper.BusinessConnString, CommandType.Text, "select * from s_settings where keyname like 'FTP%'");
                string _csms_FTPUrl = ds.Tables[0].Select("KEYNAME='FTPUrl'")[0]["CONFIGVALUE"].ToString();// Platform.Common.KeyValueHelper.GetValue("FTPUrl");
                string _CSMS_PATH = ConfigurationManager.AppSettings["CSMS_PATH"];
                string _csms_FTPUsername = ds.Tables[0].Select("KEYNAME='FTPUsername'")[0]["CONFIGVALUE"].ToString();// Platform.Common.KeyValueHelper.GetValue("FTPUsername");
                string _csms_FTPPassword = ds.Tables[0].Select("KEYNAME='FTPPassword'")[0]["CONFIGVALUE"].ToString();// Platform.Common.KeyValueHelper.GetValue("FTPPassword");
                _ftp_csms = new FtpWeb(_csms_FTPUrl, _CSMS_PATH, _csms_FTPUsername, _csms_FTPPassword);
            }
            AccessDataBase adBase = new AccessDataBase();
            if (paraCertList != null && paraCertList.Count > 0)
            {
                foreach (CertList per in paraCertList)
                {
                    try
                    {
                        WTB_WENJIANXX _WTB_WENJIANXX = new WTB_WENJIANXX()
                        {
                            ID = 0,
                            INCIDENT_ID = WTB_YEWUZB.INCIDENT_ID,
                            S_ZHUBIAOBH = WTB_YEWUZB.S_ZHUBIAOBH,
                            CERT_SOURCE = per.cert_source,
                            CERT_TYPE = per.cert_type,
                            CERT_NUMBER = per.cert_number,
                            FILE_UUID = per.file_uuid,
                            FILENAME = per.filename,
                            WEB_URI = per.web_uri
                        };
                        if (WTB_YEWUZB.INCIDENT_TYPE == "McsItemType.MultiHousehold")
                        {
                            _WTB_WENJIANXX.S_BEIYONG1 = per.app_type + "|" + per.bus_type;
                            _WTB_WENJIANXX.S_BEIYONG2 = per.name;
                            _WTB_WENJIANXX.S_BEIYONG3 = per.cert_address + "|" + per.address_check;
                            if (per.cert_effect_date != "")
                                _WTB_WENJIANXX.D_BEIYONG1 = Convert.ToDateTime(per.cert_effect_date);
                            if (per.cert_expire_date != "")
                                _WTB_WENJIANXX.D_BEIYONG2 = Convert.ToDateTime(per.cert_expire_date);
                        }

                        if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["FTP_IP"]))
                        {
                            //_ftp_wtb.ftpURI = _ftp_wtb.ftpURI + per.web_uri.Replace(per.filename, "");
                            if (!_ftp_wtb.ftpURI.Contains(WTB_YEWUZB.INCIDENT_ID) && (WTB_YEWUZB.BUSINESS_TYPE == "25"))
                            {
                                //2023/5/McsItemType.UniTransfer
                                _ftp_wtb.ftpURI = _ftp_wtb.ftpURI + Convert.ToDateTime(WTB_YEWUZB.APPDATE).ToString("yyyy") + "/" + Convert.ToInt32(Convert.ToDateTime(WTB_YEWUZB.APPDATE).ToString("MM")).ToString() + "/" + WTB_YEWUZB.INCIDENT_TYPE + "/" + WTB_YEWUZB.INCIDENT_ID + "/";
                            }
                            else if (!_ftp_wtb.ftpURI.Contains(WTB_YEWUZB.INCIDENT_ID) && (WTB_YEWUZB.BUSINESS_TYPE == "26"))
                            {
                                //2023/5/McsItemType.UniTransfer
                                _ftp_wtb.ftpURI = _ftp_wtb.ftpURI + Convert.ToDateTime(WTB_YEWUZB.APPDATE).ToString("yyyy") + "/" + Convert.ToInt32(Convert.ToDateTime(WTB_YEWUZB.APPDATE).ToString("MM")).ToString() + "/" + "McsItemType.UniTransfer" + "/" + WTB_YEWUZB.INCIDENT_ID + "/";
                            } 
                            else if (!_ftp_wtb.ftpURI.Contains(WTB_YEWUZB.INCIDENT_ID) && WTB_YEWUZB.BUSINESS_TYPE != "25" && WTB_YEWUZB.BUSINESS_TYPE == "26")
                            {
                                _ftp_wtb.ftpURI = _ftp_wtb.ftpURI + WTB_YEWUZB.INCIDENT_ID + "/";
                            }

                            Directory.CreateDirectory(ConfigurationManager.AppSettings["LocalMediaFiles"] + "/" + WTB_YEWUZB.INCIDENT_ID);
                            LogUtil.Info("下载文件:" + ConfigurationManager.AppSettings["FTP_IP"] + "16022;" + ConfigurationManager.AppSettings["FTP_ACCOUNT"] + "|" + ConfigurationManager.AppSettings["FTP_PWD"] + _ftp_wtb.ftpURI + _WTB_WENJIANXX.FILENAME + "到本地。");

                            String Download = ConfigurationManager.AppSettings["DownloadFile"];
                            if (Download == "1")//0 下载 ,1 不下载
                            {
                                adBase.InsertWTB_WENJIANXX(_WTB_WENJIANXX, null);
                                LogUtil.Info("放弃下载文件:" + Download.ToString());
                                return true;
                            }
                            if (Environment == "TEST")
                            {
                                i_Rtn_Count += adBase.InsertWTB_WENJIANXX(_WTB_WENJIANXX, null) > 0 ? 1 : 0;
                                LogUtil.Info("下载文件:" + ConfigurationManager.AppSettings["FTP_IP"] + ConfigurationManager.AppSettings["FTP_ACCOUNT"] + "|" + ConfigurationManager.AppSettings["FTP_PWD"] + _ftp_wtb.ftpURI + _WTB_WENJIANXX.FILENAME + "到本地。");
                                //LogUtil.Info("本地文件存放地址：" + ConfigurationManager.AppSettings["LocalMediaFiles"] + "\\ChanZheng" + "\\" + Filename);

                                _ftp_wtb.Download(ConfigurationManager.AppSettings["LocalMediaFiles"] + "/" + WTB_YEWUZB.INCIDENT_ID, _WTB_WENJIANXX.FILENAME);
                            }
                            else
                            {
                                i_Rtn_Count += adBase.InsertWTB_WENJIANXX(_WTB_WENJIANXX, null) > 0 ? 1 : 0;
                                _ftp_wtb.SFTPOperation(ConfigurationManager.AppSettings["FTP_IP"], "16022", ConfigurationManager.AppSettings["FTP_ACCOUNT"], ConfigurationManager.AppSettings["FTP_PWD"]);
                                if (WTB_YEWUZB.BUSINESS_TYPE == "25")
                                {
                                    _ftp_wtb.DownloadSFTP("/" + ConfigurationManager.AppSettings["FTP_PATH"] + "/" + Convert.ToDateTime(WTB_YEWUZB.APPDATE).ToString("yyyy") + "/" + Convert.ToInt32(Convert.ToDateTime(WTB_YEWUZB.APPDATE).ToString("MM")) + "/" + WTB_YEWUZB.INCIDENT_TYPE + "/" + WTB_YEWUZB.INCIDENT_ID + "/" + _WTB_WENJIANXX.FILENAME, ConfigurationManager.AppSettings["LocalMediaFiles"] + "/" + WTB_YEWUZB.INCIDENT_ID, _WTB_WENJIANXX.FILENAME);
                                }
                                else if (WTB_YEWUZB.BUSINESS_TYPE == "26")
                                {
                                    _ftp_wtb.DownloadSFTP("/" + ConfigurationManager.AppSettings["FTP_PATH"] + "/" + Convert.ToDateTime(WTB_YEWUZB.APPDATE).ToString("yyyy") + "/" + Convert.ToInt32(Convert.ToDateTime(WTB_YEWUZB.APPDATE).ToString("MM")) + "/" + "McsItemType.UniTransfer" + "/" + WTB_YEWUZB.INCIDENT_ID + "/" + _WTB_WENJIANXX.FILENAME, ConfigurationManager.AppSettings["LocalMediaFiles"] + "/" + WTB_YEWUZB.INCIDENT_ID, _WTB_WENJIANXX.FILENAME);
                                }
                                else
                                {
                                    _ftp_wtb.DownloadSFTP("/" + ConfigurationManager.AppSettings["FTP_PATH"] + "/" + WTB_YEWUZB.INCIDENT_ID + "/" + _WTB_WENJIANXX.FILENAME, ConfigurationManager.AppSettings["LocalMediaFiles"] + "/" + WTB_YEWUZB.INCIDENT_ID, _WTB_WENJIANXX.FILENAME);
                                }
                                //_ftp_wtb.DownloadSFTP("/" + ConfigurationManager.AppSettings["FTP_PATH"] + "/" + WTB_YEWUZB.INCIDENT_ID + "/" + _WTB_WENJIANXX.FILENAME, ConfigurationManager.AppSettings["LocalMediaFiles"] + "/" + WTB_YEWUZB.INCIDENT_ID, _WTB_WENJIANXX.FILENAME);
                            }
                            //_ftp_wtb.Download(ConfigurationManager.AppSettings["LocalMediaFiles"] + "/" + WTB_YEWUZB.INCIDENT_ID, _WTB_WENJIANXX.FILENAME);
                            LogUtil.Info("上传文件:" + _WTB_WENJIANXX.FILENAME + "到CSMS服务器");
                            _ftp_csms.MakeDir(WTB_YEWUZB.INCIDENT_ID);
                            if (!_ftp_csms.ftpURI.Contains(WTB_YEWUZB.INCIDENT_ID))
                            {
                                _ftp_csms.ftpURI = _ftp_csms.ftpURI + WTB_YEWUZB.INCIDENT_ID + "/";
                            }
                            if (_ftp_csms.Upload(ConfigurationManager.AppSettings["LocalMediaFiles"] + "/" + WTB_YEWUZB.INCIDENT_ID + "/" + _WTB_WENJIANXX.FILENAME))
                            {
                                //LogUtil.Info("移除本地文件:" + _WTB_WENJIANXX.FILENAME);
                                //File.Delete(ConfigurationManager.AppSettings["LocalMediaFiles"] + "//" + _WTB_WENJIANXX.FILENAME);                          
                            }
                        }
                        else
                        {
                            LogUtil.Info("InsertWTB_WENJIANXX 处理开始{0}", _WTB_WENJIANXX.FILENAME);
                            i_Rtn_Count += adBase.InsertWTB_WENJIANXX(_WTB_WENJIANXX, null) > 0 ? 1 : 0;
                            LogUtil.Info("InsertWTB_WENJIANXX 处理结束{0}", _WTB_WENJIANXX.FILENAME);
                        }
                        string[] baoxiulx = { "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "29", "35" };//报修业务类型
                        if (STR_CURRENT_COMPANY == "PDWLY" && baoxiulx.Contains(WTB_YEWUZB.BUSINESS_TYPE))
                        {
                            repairFile _file = new repairFile();
                            _file.third_id = WTB_YEWUZB.INCIDENT_ID;
                            _file.cert_type = per.cert_type;
                            _file.cert_source = per.cert_source;
                            _file.cert_number = per.cert_number;
                            _file.file_uuid = per.file_uuid;
                            _file.filename = per.filename;
                            _file.File = FileToStream(ConfigurationManager.AppSettings["LocalMediaFiles"] + "/" + WTB_YEWUZB.INCIDENT_ID + "/" + _WTB_WENJIANXX.FILENAME);
                            //string body = JsonConvert.SerializeObject(_file);
                            //QueryPostWebService(URL_BAOXIU_HOT, "UploadFlieDate", body);

                            LogUtil.Info("调用水务之声文件流接口开始。。。。" + _file.filename);
                            if (_file.File == null)
                            {
                                LogUtil.Info("文件为空");
                            }
                            string msg = postFile(_file, URL_BAOXIU_HOT + "/UploadFlieDate");
                            LogUtil.Info("调用水务之声文件流接口结束。。。。" + msg);
                        }
                    }
                    catch
                    {
                        continue;
                    }
                }
            }
            return true; 
                //paraCertList == null || paraCertList.Count == 0 || (paraCertList.Count > 0 && paraCertList.Count == i_Rtn_Count) ? true : false;
        }

        /// <summary>
        /// 上传附件到CSMS文件服务器
        /// </summary>
        /// <param name="s_biaohao">父文件夹，为空则不建立</param>
        /// <param name="filepathname">本地完整路径的文件名</param>
        /// <returns></returns>
        public bool UploadFile2CSMS(string s_biaohao, string filepathname)
        {
            bool result = false;
            try
            {
                FtpWeb _ftp_csms = null;
                DataSet ds = Platform.Data.OracleHelper.ExecuteDataset(Platform.Configuration.ConfigHelper.BusinessConnString, CommandType.Text, "select * from s_settings where keyname like 'FTP%'");
                string _csms_FTPUrl = ds.Tables[0].Select("KEYNAME='FTPUrl'")[0]["CONFIGVALUE"].ToString();// Platform.Common.KeyValueHelper.GetValue("FTPUrl");
                string _CSMS_PATH = ConfigurationManager.AppSettings["CSMS_PATH"];
                string _csms_FTPUsername = ds.Tables[0].Select("KEYNAME='FTPUsername'")[0]["CONFIGVALUE"].ToString();// Platform.Common.KeyValueHelper.GetValue("FTPUsername");
                string _csms_FTPPassword = ds.Tables[0].Select("KEYNAME='FTPPassword'")[0]["CONFIGVALUE"].ToString();// Platform.Common.KeyValueHelper.GetValue("FTPPassword");
                _ftp_csms = new FtpWeb(_csms_FTPUrl, _CSMS_PATH, _csms_FTPUsername, _csms_FTPPassword);
                FileInfo _file = new FileInfo(filepathname);
                if (!string.IsNullOrEmpty(s_biaohao))
                    _ftp_csms.MakeDir(s_biaohao);
                if (!_ftp_csms.ftpURI.Contains(s_biaohao))
                {
                    _ftp_csms.ftpURI = _ftp_csms.ftpURI + s_biaohao + "/";
                }
                result = _ftp_csms.Upload(filepathname);
            }
            catch (Exception e)
            {
                LogUtil.Error("上传CSMS文件异常:{0}", e.Message);
                throw e;
            }
            return result;
        }

        /// <summary>
        /// 从文件读取 Stream
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public Stream FileToStream(string fileName)
        {

            // 打开文件 
            FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);

            // 读取文件的 byte[] 
            byte[] bytes = new byte[fileStream.Length];

            fileStream.Read(bytes, 0, bytes.Length);

            fileStream.Close();

            // 把 byte[] 转换成 Stream 
            Stream stream = new MemoryStream(bytes);

            return stream;

        }
        /// <summary>
        /// 根据方法获取参数名称和值
        /// </summary>
        /// <returns></returns>
        public string GetParameterByMethod(int i_WsNo, object rpEntity)
        {
            StringBuilder sb = new StringBuilder();
            switch (i_WsNo)
            {
                case (int)Web_Service_Name.Repair:
                    #region 报修
                    RepairEntity repairEntity = (RepairEntity)rpEntity;
                    sb.AppendFormat("{0}={1}|", "incident_id", repairEntity.incident_id);
                    sb.AppendFormat("{0}={1}|", "apply_no", repairEntity.apply_no);
                    sb.AppendFormat("{0}={1}|", "custom_type", repairEntity.custom_type);
                    sb.AppendFormat("{0}={1}|", "shw_address", repairEntity.shw_address);
                    sb.AppendFormat("{0}={1}|", "applicant", repairEntity.applicant);
                    sb.AppendFormat("{0}={1}|", "appdate", repairEntity.appdate);
                    sb.AppendFormat("{0}={1}|", "incident_type", repairEntity.incident_type);
                    //sb.AppendFormat("{0}={1}|", "cert_type", repairEntity.cert_type);
                    sb.AppendFormat("{0}={1}|", "cert_number", repairEntity.cert_number);
                    sb.AppendFormat("{0}={1}|", "email", repairEntity.email);
                    sb.AppendFormat("{0}={1}|", "company_name", repairEntity.company_name);
                    sb.AppendFormat("{0}={1}|", "company_type", repairEntity.company_type);
                    sb.AppendFormat("{0}={1}|", "social_credit_code", repairEntity.social_credit_code);
                    sb.AppendFormat("{0}={1}|", "case_type_cd", repairEntity.case_type_cd);
                    sb.AppendFormat("{0}={1}|", "card_id", repairEntity.card_id);
                    sb.AppendFormat("{0}={1}|", "address", repairEntity.address);
                    sb.AppendFormat("{0}={1}|", "contact_value", repairEntity.contact_value);
                    sb.AppendFormat("{0}={1}|", "fyly", repairEntity.fyly);
                    sb.AppendFormat("{0}={1}|", "fyxs", repairEntity.fyxs);
                    sb.AppendFormat("{0}={1}|", "fyqm", repairEntity.fyqm);
                    sb.AppendFormat("{0}={1}|", "fylb", repairEntity.fylb);
                    sb.AppendFormat("{0}={1}|", "fynr", repairEntity.fynr);
                    sb.AppendFormat("{0}={1}|", "bx_dttm", repairEntity.bx_dttm);
                    sb.AppendFormat("{0}={1}|", "cljb", repairEntity.cljb);
                    sb.AppendFormat("{0}={1}|", "cn_dttm", repairEntity.cn_dttm);
                    sb.AppendFormat("{0}={1}|", "bx_loc_cd", repairEntity.bx_loc_cd);
                    sb.AppendFormat("{0}={1}|", "repair_comment", repairEntity.repair_comment);
                    #endregion
                    break;
                case (int)Web_Service_Name.CompanyApply:
                    #region 单位接水
                    CompanyApplyEntity companyApplyEntity = (CompanyApplyEntity)rpEntity;
                    sb.AppendFormat("{0}={1}|", "incident_id", companyApplyEntity.incident_id);
                    sb.AppendFormat("{0}={1}|", "apply_no", companyApplyEntity.apply_no);
                    sb.AppendFormat("{0}={1}|", "shw_address", companyApplyEntity.shw_address);
                    sb.AppendFormat("{0}={1}|", "applicant", companyApplyEntity.applicant);
                    sb.AppendFormat("{0}={1}|", "appdate", companyApplyEntity.appdate);
                    sb.AppendFormat("{0}={1}|", "cert_type", companyApplyEntity.cert_type);
                    sb.AppendFormat("{0}={1}|", "cert_number", companyApplyEntity.cert_number);
                    sb.AppendFormat("{0}={1}|", "email", companyApplyEntity.email);
                    sb.AppendFormat("{0}={1}|", "company_name", companyApplyEntity.company_name);
                    sb.AppendFormat("{0}={1}|", "company_type", companyApplyEntity.company_type);
                    sb.AppendFormat("{0}={1}|", "social_credit_code", companyApplyEntity.social_credit_code);
                    sb.AppendFormat("{0}={1}|", "business_type", companyApplyEntity.business_type);
                    sb.AppendFormat("{0}={1}|", "address", companyApplyEntity.address);
                    sb.AppendFormat("{0}={1}|", "apply_content", companyApplyEntity.apply_content);
                    sb.AppendFormat("{0}={1}|", "project", companyApplyEntity.project);
                    sb.AppendFormat("{0}={1}|", "contact_person", companyApplyEntity.contact_person);
                    sb.AppendFormat("{0}={1}|", "phone", companyApplyEntity.phone);
                    sb.AppendFormat("{0}={1}|", "mail", companyApplyEntity.mail);
                    sb.AppendFormat("{0}={1}|", "ysxqsc", companyApplyEntity.ysxqsc);
                    sb.AppendFormat("{0}={1}|", "ysxqxf", companyApplyEntity.ysxqxf);
                    sb.AppendFormat("{0}={1}|", "overall_floorage", companyApplyEntity.overall_floorage);
                    sb.AppendFormat("{0}={1}|", "qyzjlx", companyApplyEntity.qyzjlx);
                    sb.AppendFormat("{0}={1}|", "qyzjbm", companyApplyEntity.qyzjbm);
                    sb.AppendFormat("{0}={1}|", "frxm", companyApplyEntity.frxm);
                    sb.AppendFormat("{0}={1}|", "frsfzhm", companyApplyEntity.frsfzhm);
                    sb.AppendFormat("{0}={1}|", "ydxz", companyApplyEntity.ydxz);
                    sb.AppendFormat("{0}={1}|", "build_type", companyApplyEntity.build_type);
                    sb.AppendFormat("{0}={1}|", "wygz", companyApplyEntity.wygz);
                    sb.AppendFormat("{0}={1}|", "khxz", companyApplyEntity.khxz);
                    sb.AppendFormat("{0}={1}|", "sqlb", companyApplyEntity.sqlb);
                    if (companyApplyEntity.CertList != null && companyApplyEntity.CertList.Count > 0)
                    {
                        foreach (CertList per in companyApplyEntity.CertList)
                        {
                            sb.AppendFormat(@"cert_source={0},cert_type={1},cert_number={2},file_uuid={3},filename={4},web_uri={5}|",
                                              per.cert_source, per.cert_type, per.cert_number, per.file_uuid, per.filename, per.web_uri);
                        }
                    }
                    #endregion
                    break;
                case (int)Web_Service_Name.ResidentApply:
                    #region 居民住宅单独接水
                    ResidentApplyEntity residentApplyEntity = (ResidentApplyEntity)rpEntity;
                    sb.AppendFormat("{0}={1}|", "incident_id", residentApplyEntity.incident_id);
                    sb.AppendFormat("{0}={1}|", "apply_no", residentApplyEntity.apply_no);
                    sb.AppendFormat("{0}={1}|", "shw_address", residentApplyEntity.shw_address);
                    sb.AppendFormat("{0}={1}|", "applicant", residentApplyEntity.applicant);
                    sb.AppendFormat("{0}={1}|", "appdate", residentApplyEntity.appdate);
                    sb.AppendFormat("{0}={1}|", "incident_type", residentApplyEntity.incident_type);
                    sb.AppendFormat("{0}={1}|", "cert_type", residentApplyEntity.cert_type);
                    sb.AppendFormat("{0}={1}|", "cert_number", residentApplyEntity.cert_number);
                    sb.AppendFormat("{0}={1}|", "business_type", residentApplyEntity.business_type);
                    sb.AppendFormat("{0}={1}|", "address", residentApplyEntity.address);
                    sb.AppendFormat("{0}={1}|", "apply_content", residentApplyEntity.apply_content);
                    sb.AppendFormat("{0}={1}|", "con_name", residentApplyEntity.con_name);
                    sb.AppendFormat("{0}={1}|", "phone", residentApplyEntity.phone);
                    sb.AppendFormat("{0}={1}|", "mail", residentApplyEntity.mail);
                    sb.AppendFormat("{0}={1}|", "contact_address", residentApplyEntity.contact_address);
                    if (residentApplyEntity.CertList != null && residentApplyEntity.CertList.Count > 0)
                    {
                        foreach (CertList per in residentApplyEntity.CertList)
                        {
                            sb.AppendFormat(@"cert_source={0},cert_type={1},cert_number={2},file_uuid={3},filename={4},web_uri={5}|",
                                              per.cert_source, per.cert_type, per.cert_number, per.file_uuid, per.filename, per.web_uri);
                        }
                    }
                    #endregion
                    break;
                case (int)Web_Service_Name.Transfer:
                    #region 居民过户/单位过户
                    TransferEntity transferEntity = (TransferEntity)rpEntity;
                    sb.AppendFormat("{0}={1}|", "incident_id", transferEntity.incident_id);
                    sb.AppendFormat("{0}={1}|", "apply_no", transferEntity.apply_no);
                    sb.AppendFormat("{0}={1}|", "custom_type", transferEntity.custom_type);
                    sb.AppendFormat("{0}={1}|", "applicant", transferEntity.applicant);
                    sb.AppendFormat("{0}={1}|", "appdate", transferEntity.appdate);
                    //sb.AppendFormat("{0}={1}|", "cert_type", transferEntity.cert_type);
                    sb.AppendFormat("{0}={1}|", "cert_number", transferEntity.cert_number);
                    sb.AppendFormat("{0}={1}|", "email", transferEntity.email);
                    sb.AppendFormat("{0}={1}|", "company_name", transferEntity.company_name);
                    sb.AppendFormat("{0}={1}|", "company_type", transferEntity.company_type);
                    sb.AppendFormat("{0}={1}|", "business_type", transferEntity.business_type);
                    sb.AppendFormat("{0}={1}|", "card_id", transferEntity.card_id);
                    sb.AppendFormat("{0}={1}|", "new_entity_name", transferEntity.new_entity_name);
                    sb.AppendFormat("{0}={1}|", "id_type", transferEntity.id_type);
                    sb.AppendFormat("{0}={1}|", "id_nbr", transferEntity.id_nbr);
                    sb.AppendFormat("{0}={1}|", "fczjlx", transferEntity.fczjlx);
                    sb.AppendFormat("{0}={1}|", "fczjhm", transferEntity.fczjhm);
                    sb.AppendFormat("{0}={1}|", "address", transferEntity.address);
                    sb.AppendFormat("{0}={1}|", "comm_rte_type_cd", transferEntity.comm_rte_type_cd);
                    sb.AppendFormat("{0}={1}|", "contact_value", transferEntity.contact_value);
                    sb.AppendFormat("{0}={1}|", "gyshtbh", transferEntity.gyshtbh);
                    sb.AppendFormat("{0}={1}|", "fplx", transferEntity.fplx);
                    sb.AppendFormat("{0}={1}|", "fptt", transferEntity.fptt);
                    sb.AppendFormat("{0}={1}|", "nsrsbh", transferEntity.nsrsbh);
                    sb.AppendFormat("{0}={1}|", "ysrks", transferEntity.ysrks);
                    sb.AppendFormat("{0}={1}|", "transfer_comment", transferEntity.transfer_comment);
                    sb.AppendFormat("{0}={1}|", "typc", transferEntity.typc);
                    if (transferEntity.CertList != null && transferEntity.CertList.Count > 0)
                    {
                        foreach (CertList per in transferEntity.CertList)
                        {
                            sb.AppendFormat(@"cert_source={0},cert_type={1},cert_number={2},file_uuid={3},filename={4},web_uri={5}|",
                                               per.cert_source, per.cert_type, per.cert_number, per.file_uuid, per.filename, per.web_uri);
                        }
                    }
                    #endregion
                    break;
                case (int)Web_Service_Name.WatermeterSplit:
                    #region 居民住宅总表分装
                    WatermeterSplitEntity waterSplitEntity = (WatermeterSplitEntity)rpEntity;
                    sb.AppendFormat("{0}={1}|", "incident_id", waterSplitEntity.incident_id);
                    sb.AppendFormat("{0}={1}|", "apply_no", waterSplitEntity.apply_no);
                    sb.AppendFormat("{0}={1}|", "shw_address", waterSplitEntity.shw_address);
                    sb.AppendFormat("{0}={1}|", "applicant", waterSplitEntity.applicant);
                    sb.AppendFormat("{0}={1}|", "appdate", waterSplitEntity.appdate);
                    sb.AppendFormat("{0}={1}|", "incident_type", waterSplitEntity.incident_type);
                    sb.AppendFormat("{0}={1}|", "cert_type", waterSplitEntity.cert_type);
                    sb.AppendFormat("{0}={1}|", "cert_number", waterSplitEntity.cert_number);
                    sb.AppendFormat("{0}={1}|", "email", waterSplitEntity.email);
                    sb.AppendFormat("{0}={1}|", "business_type", waterSplitEntity.business_type);
                    sb.AppendFormat("{0}={1}|", "address", waterSplitEntity.address);
                    sb.AppendFormat("{0}={1}|", "con_name", waterSplitEntity.con_name);
                    sb.AppendFormat("{0}={1}|", "contact_value", waterSplitEntity.contact_value);
                    sb.AppendFormat("{0}={1}|", "phone", waterSplitEntity.phone);
                    sb.AppendFormat("{0}={1}|", "mail", waterSplitEntity.mail);
                    sb.AppendFormat("{0}={1}|", "yb", waterSplitEntity.yb);
                    sb.AppendFormat("{0}={1}|", "split_comment", waterSplitEntity.split_comment);
                    if (waterSplitEntity.CertList != null && waterSplitEntity.CertList.Count > 0)
                    {
                        foreach (CertList per in waterSplitEntity.CertList)
                        {
                            sb.AppendFormat(@"cert_source={0},cert_type={1},cert_number={2},file_uuid={3},filename={4},web_uri={5}|",
                                             per.cert_source, per.cert_type, per.cert_number, per.file_uuid, per.filename, per.web_uri);
                        }
                    }
                    #endregion
                    break;
            }
            return sb.ToString();
        }

        public DataTable JsonToDataTable(string strJson)
        {
            //取出表名   
            var rg = new Regex(@"(?<={)[^:]+(?=:\[)", RegexOptions.IgnoreCase);
            string strName = rg.Match(strJson).Value;
            DataTable tb = null;
            //去除表名 
            if (strJson.IndexOf("[") > 0)
                strJson = strJson.Substring(strJson.IndexOf("[") + 1);
            if (strJson.IndexOf("]") > 0)
                strJson = strJson.Substring(0, strJson.IndexOf("]"));
            //获取数据   
            rg = new Regex(@"(?<={)[^}]+(?=})");
            MatchCollection mc = rg.Matches(strJson);
            for (int i = 0; i < mc.Count; i++)
            {
                string strRow = mc[i].Value;
                string[] strRows = strRow.Split(',');
                //创建表   
                if (tb == null)
                {
                    tb = new DataTable();
                    tb.TableName = strName;
                    foreach (string str in strRows)
                    {
                        var dc = new DataColumn();
                        string[] strCell = str.Split(':');
                        dc.ColumnName = strCell[0].Replace("\"", "").Trim();
                        if (dc.ColumnName == "D_CHAOBIAORQ" || dc.ColumnName == "D_HUANBIAORQ" || dc.ColumnName.Contains("D_"))
                            dc.DataType = typeof(DateTime);
                        tb.Columns.Add(dc);
                    }
                    tb.AcceptChanges();
                }
                //增加内容   
                DataRow dr = tb.NewRow();
                for (int r = 0; r < strRows.Length; r++)
                {
                    dr[r] = strRows[r].Substring(strRows[r].IndexOf(':') + 1).Replace("\"", "");//Split(':')[1].Trim().Replace("，", ",").Replace("：",  ":").Replace("\"", "");
                }
                tb.Rows.Add(dr);
                tb.AcceptChanges();
            }
            return tb;
        }

        /// <summary>
        /// 获取时间戳
        /// </summary>
        /// <returns></returns>
        public string GetTimeStamp()
        {
            TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            return Convert.ToInt64(ts.TotalSeconds).ToString();
        }

        /// <summary>
        /// 将时间戳转换为日期
        /// </summary>
        /// <param name="timeStamp"></param>
        /// <returns></returns>
        //public DateTime StampToDateTime(string timeStamp)
        //{
        //    DateTime dateTimeStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
        //    long lTime = long.Parse(timeStamp + "0000000");
        //    TimeSpan toNow = new TimeSpan(lTime);
        //    return dateTimeStart.Add(toNow);
        //}
        public DateTime StampToDateTime(TimeSpan timeStamp)
        {
            DateTime dateTimeStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
            TimeSpan toNow = timeStamp;
            return dateTimeStart.Add(toNow);
        }

        /// <summary>
        /// 将Unix时间戳转换为dateTime格式
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        public static DateTime UnixTimeToDateTime(int time)
        {
            if (time < 0)
                throw new ArgumentOutOfRangeException("time is out of range");

            return TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddSeconds(time);
        }


        /// <summary>
        /// 将Unix时间戳转换为dateTime格式(返回结果字符串)
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        public static string UnixTimeToDateTimeStr(int time)
        {
            if (time < 0)
                throw new ArgumentOutOfRangeException("time is out of range");

            return TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddSeconds(time).ToShortDateString().Replace("/", "-");
        }
        /// <summary>
        /// Web调用
        /// </summary>
        /// <param name="URL"></param>
        /// <param name="MethodName"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public string QueryPostWebService(String URL, String MethodName, string body)
        {
            try
            {
                string rid = System.Guid.NewGuid().ToString();

                string t = GetTimeStamp();
                LogUtil.Info("开始请求地址：" + URL + "/" + MethodName + "?rid=" + rid + "&t=" + t + "");
                LogUtil.Info("请求参数：" + body);

                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL + "/" + MethodName + "?rid=" + rid + "&t=" + t + "");
                request.ProtocolVersion = HttpVersion.Version10;
                //ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
                LogUtil.Info("协议版本：" + request.ProtocolVersion.ToString() + ";" + ServicePointManager.SecurityProtocol.ToString());
                ServicePointManager.ServerCertificateValidationCallback = new
    RemoteCertificateValidationCallback
    (
       delegate { return true; }
    );

                request.Method = "POST";
                //request.ContentType = "text/xml; charset=utf-8";
                //request.ContentType = "application/x-www-form-urlencoded";
                request.ContentType = "application/json";//charset=UTF-8
                Encoding encoding = Encoding.UTF8;
                /// 设置凭证与超时时间
                request.Credentials = CredentialCache.DefaultCredentials;
                request.KeepAlive = false;
                //request.ProtocolVersion = HttpVersion.Version11;
                request.Timeout = Convert.ToInt32(XIAODANTIMEOUT);//设置timeout 10S
                byte[] buffer = encoding.GetBytes(body);
                request.ContentLength = buffer.Length;
                request.GetRequestStream().Write(buffer, 0, buffer.Length);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
                {
                    return reader.ReadToEnd();
                }
            }
            catch(Exception ex )
            {
                LogUtil.Info("调用请求错误信息：" + ex.Message);
                return "";
            }
        }

        /// <summary>
        /// Web调用
        /// </summary>
        /// <param name="URL"></param>
        /// <param name="MethodName"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public string QueryPostWebServiceNEW(String URL, String MethodName, string body)
        {
            try
            {
                string rid = System.Guid.NewGuid().ToString();

                string t = GetTimeStamp();
                LogUtil.Info("开始请求地址：" + URL + "/" + MethodName + "?rid=" + rid + "&t=" + t + "");
                LogUtil.Info("请求参数：" + body);

                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL + "/" + MethodName + "?rid=" + rid + "&t=" + t + "");
                //request.ProtocolVersion = HttpVersion;
                ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
                LogUtil.Info("协议版本：" + request.ProtocolVersion.ToString() + ";" + ServicePointManager.SecurityProtocol.ToString());
                ServicePointManager.ServerCertificateValidationCallback = new
    RemoteCertificateValidationCallback
    (
       delegate { return true; }
    );

                request.Method = "POST";
                //request.ContentType = "text/xml; charset=utf-8";
                //request.ContentType = "application/x-www-form-urlencoded";
                request.ContentType = "application/json";//charset=UTF-8
                Encoding encoding = Encoding.UTF8;
                /// 设置凭证与超时时间
                request.Credentials = CredentialCache.DefaultCredentials;
                request.KeepAlive = false;
                //request.ProtocolVersion = HttpVersion.Version11;
                request.Timeout = Convert.ToInt32(XIAODANTIMEOUT);//设置timeout 10S
                byte[] buffer = encoding.GetBytes(body);
                request.ContentLength = buffer.Length;
                request.GetRequestStream().Write(buffer, 0, buffer.Length);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
                {
                    return reader.ReadToEnd();
                }
            }
            catch (Exception ex)
            {
                LogUtil.Info("调用请求错误信息：" + ex.Message);
                return "";
            }
        }

        public string QueryPostHttpsWebService(String URL, String MethodName, string body)
        {
            string rid = System.Guid.NewGuid().ToString();

            string t = GetTimeStamp();
            LogUtil.Info("开始请求地址：" + URL + "/" + MethodName + "?rid=" + rid + "&t=" + t + "");
            LogUtil.Info("请求参数：" + body);

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL + "/" + MethodName + "?rid=" + rid + "&t=" + t + "");
            request.ProtocolVersion = HttpVersion.Version10;
            ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)3072;
            LogUtil.Info("协议版本：" + request.ProtocolVersion.ToString() + ";" + ServicePointManager.SecurityProtocol.ToString());
            ServicePointManager.ServerCertificateValidationCallback = new
RemoteCertificateValidationCallback
(
   delegate { return true; }
);



            ServicePointManager.CheckCertificateRevocationList = true;
            ServicePointManager.DefaultConnectionLimit = 1000;
            ServicePointManager.Expect100Continue = false;
            request.Method = "POST";
            //request.ContentType = "text/xml; charset=utf-8";
            //request.ContentType = "application/x-www-form-urlencoded";
            request.ContentType = "application/json";//charset=UTF-8
            Encoding encoding = Encoding.UTF8;
            /// 设置凭证与超时时间
            request.Credentials = CredentialCache.DefaultCredentials;
            request.KeepAlive = false;
            //request.ProtocolVersion = HttpVersion.Version11;
            request.Timeout = Convert.ToInt32(XIAODANTIMEOUT);//设置timeout 10S
            byte[] buffer = encoding.GetBytes(body);
            request.ContentLength = buffer.Length;
            request.GetRequestStream().Write(buffer, 0, buffer.Length);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
            {
                return reader.ReadToEnd();
            }
        }

        public bool SavePDFStream(string sPDF_Url,string body,string localfilename)
        {
            try
            {
                string tempPath = System.IO.Path.GetDirectoryName(localfilename) + @"\emp";
                System.IO.Directory.CreateDirectory(tempPath);  //创建临时文件目录
                string tempFile = tempPath + @"\" + System.IO.Path.GetFileName(localfilename); //临时文件
                if (System.IO.File.Exists(tempFile))
                {
                    System.IO.File.Delete(tempFile);    //存在则删除
                }
                if (System.IO.File.Exists(localfilename))
                {
                    return true;
                }
                FileStream fs = new FileStream(tempFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
               

                LogUtil.Info("开始请求地址：" + sPDF_Url);

                ServicePointManager.ServerCertificateValidationCallback = new
    RemoteCertificateValidationCallback
    (
    delegate { return true; }
    );

                //HttpContext _context = HttpContext.Current;
                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(sPDF_Url);
                request.Method = "POST";
                request.ContentType = "application/json";//charset=UTF-8
                Encoding encoding = Encoding.UTF8;

                /// 设置凭证与超时时间
                request.Credentials = CredentialCache.DefaultCredentials;
                request.KeepAlive = false;
                request.ProtocolVersion = HttpVersion.Version10;
                request.Timeout = Convert.ToInt32(XIAODANTIMEOUT);//设置timeout 10S
                byte[] buffer = encoding.GetBytes(body);
                request.ContentLength = buffer.Length;
                request.GetRequestStream().Write(buffer, 0, buffer.Length);

                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                
                using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
                {
                    int length = 1024;
                    byte[] bs = new byte[length];
                    Stream stream = response.GetResponseStream();
                    byte[] buffer1 = new byte[length];
                    int i;
                    while ((i = stream.Read(buffer1, 0, buffer1.Length)) > 0)
                    {
                        fs.Write(buffer1, 0, i);
                    }
                    fs.Close();
                    stream.Close();
                    System.IO.File.Move(tempFile, localfilename);
                }
                LogUtil.Info("保存文件到本地：" + localfilename);
                return true;
            }
            catch (Exception ex)
            {
                LogUtil.Info("SavePDFStream异常：" + ex.Message);
                return false;
            }
        }


        #region 不用代码
        ///// <summary>
        ///// 生成dll文件保存到本地
        ///// </summary>
        ///// <param name="url">WebService地址</param>
        ///// <param name="className">类名</param>
        ///// <param name="methodName">方法名</param>
        ///// <param name="filePath">保存dll文件的路径</param>
        //public void CreateWebServiceDLL(string url, string className, string methodName, string filePath)
        //{
        //    // 1. 使用 WebClient 下载 WSDL 信息。
        //    WebClient web = new WebClient();
        //    Stream stream = web.OpenRead(url + "?WSDL");
        //    // 2. 创建和格式化 WSDL 文档。
        //    ServiceDescription description = ServiceDescription.Read(stream);
        //    //如果不存在就创建file文件夹
        //    if (Directory.Exists(filePath) == false)
        //    {
        //        Directory.CreateDirectory(filePath);
        //    }

        //    if (File.Exists(filePath + className + "_" + methodName + ".dll"))
        //    {
        //        //判断缓存是否过期
        //        var cachevalue = HttpRuntime.Cache.Get(className + "_" + methodName);
        //        if (cachevalue == null)
        //        {
        //            //缓存过期删除dll
        //            File.Delete(filePath + className + "_" + methodName + ".dll");
        //        }
        //        else
        //        {
        //            // 如果缓存没有过期直接返回
        //            return;
        //        }
        //    }

        //    // 3. 创建客户端代理代理类。
        //    ServiceDescriptionImporter importer = new ServiceDescriptionImporter();
        //    // 指定访问协议。
        //    importer.ProtocolName = "Soap";
        //    // 生成客户端代理。
        //    importer.Style = ServiceDescriptionImportStyle.Client;
        //    importer.CodeGenerationOptions = CodeGenerationOptions.GenerateProperties | CodeGenerationOptions.GenerateNewAsync;
        //    // 添加 WSDL 文档。
        //    importer.AddServiceDescription(description, null, null);
        //    // 4. 使用 CodeDom 编译客户端代理类。
        //    // 为代理类添加命名空间，缺省为全局空间。
        //    CodeNamespace nmspace = new CodeNamespace();
        //    CodeCompileUnit unit = new CodeCompileUnit();
        //    unit.Namespaces.Add(nmspace);
        //    ServiceDescriptionImportWarnings warning = importer.Import(nmspace, unit);
        //    CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");
        //    CompilerParameters parameter = new CompilerParameters();
        //    parameter.GenerateExecutable = false;
        //    // 可以指定你所需的任何文件名。
        //    parameter.OutputAssembly = filePath + className + "_" + methodName + ".dll";
        //    parameter.ReferencedAssemblies.Add("System.dll");
        //    parameter.ReferencedAssemblies.Add("System.XML.dll");
        //    parameter.ReferencedAssemblies.Add("System.Web.Services.dll");
        //    parameter.ReferencedAssemblies.Add("System.Data.dll");
        //    // 生成dll文件，并会把WebService信息写入到dll里面
        //    CompilerResults result = provider.CompileAssemblyFromDom(parameter, unit);
        //    if (result.Errors.HasErrors)
        //    {
        //        // 显示编译错误信息
        //        System.Text.StringBuilder sb = new StringBuilder();
        //        foreach (CompilerError ce in result.Errors)
        //        {
        //            sb.Append(ce.ToString());
        //            sb.Append(System.Environment.NewLine);
        //        }
        //        throw new Exception(sb.ToString());
        //    }
        //    //记录缓存
        //    var objCache = HttpRuntime.Cache;
        //    // 缓存信息写入dll文件
        //    objCache.Insert(className + "_" + methodName, "1", null, DateTime.Now.AddMinutes(5), TimeSpan.Zero, CacheItemPriority.High, null);
        //}

        ///// <summary>
        ///// 根据WebService的url地址获取className
        ///// </summary>
        ///// <param name="wsUrl">WebService的url地址</param>
        ///// <returns></returns>
        //public string GetWsClassName(string wsUrl)
        //{
        //    string[] parts = wsUrl.Split('/');
        //    string[] pps = parts[parts.Length - 1].Split('.');
        //    return pps[0];
        //}

        //public string QueryWebServiceDLL(String URL, String MethodName, object[] args)
        //{
        //    string className = GetWsClassName(URL);
        //    string filePath = HttpRuntime.AppDomainAppPath.ToString();
        //    // 调用WebServiceHelper
        //    CreateWebServiceDLL(URL, className, MethodName, filePath);
        //    // 读取dll内容
        //    byte[] filedata = File.ReadAllBytes(filePath + className + "_" + MethodName + ".dll");
        //    // 加载程序集信息
        //    Assembly asm = Assembly.Load(filedata);
        //    Type t = asm.GetType(className);
        //    // 创建实例
        //    object o = Activator.CreateInstance(t);
        //    MethodInfo method = t.GetMethod(MethodName);

        //    // 调用访问，获取方法返回值
        //    string value = method.Invoke(o, args).ToString();
        //    //输出返回值
        //    return value;
        //}

        #endregion
        /// <summary>
        /// 填充PDF模版
        /// </summary>
        /// <param name="srcPath">模版文件path，例如：../PDFFILE/城投水务二联一户多人口协议模板.pdf;</param>
        /// <param name="targetPath">新文件存放位置：例如：../PDFFILE/城投水务二联一户多人口协议20200628.pdf;</param>
        /// <param name="ds">table0 填充字段，table1 数据区域</param>
        /// <returns></returns>
        public string WritePDF(string srcPath, string targetPath, string password, DataSet ds)
        {
            try
            {
                PdfReader pdfReader = new PdfReader(srcPath);
                FileStream fs = new FileStream(targetPath+".tmp", FileMode.Create);
                PdfStamper pdfStamper = new PdfStamper(pdfReader, fs);
                AcroFields pdfFormFields = pdfStamper.AcroFields;
                BaseFont bf = BaseFont.CreateFont("C:\\Windows\\Fonts\\SimHei.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); //用系统中的字体文件SimHei.ttf创建文件字体  

                pdfFormFields.AddSubstitutionFont(bf);

                #region 填充域
                foreach (DataRow item_col in ds.Tables[1].Rows)
                {
                    string pdf_name = item_col["PDF_COLUMNNAME"].ToString();//pdf字段
                    string data_columnname=item_col["DATA_COLUMNNAME"].ToString();//数据字段
                    if (pdf_name != "NULL")
                    {
                        string value = ds.Tables[2].Rows[0][data_columnname] == DBNull.Value ? "" : ds.Tables[2].Rows[0][data_columnname].ToString();//值

                        //要输入中文就要设置域的字体;
                        pdfFormFields.SetFieldProperty(pdf_name, "textfont", bf, null);
                        pdfFormFields.SetField(pdf_name, value);
                    }
                }
                
                if (STR_CURRENT_COMPANY == "PDWLY")
                {
                    #region 合同章
                    AcroFields.FieldPosition fieldPosition = pdfStamper.AcroFields.GetFieldPositions("HONGZHANG")[0];
                    PushbuttonField imageField = new PushbuttonField(pdfStamper.Writer, fieldPosition.position, "HONGZHANG");
                    imageField.Layout = PushbuttonField.LAYOUT_ICON_ONLY;
                    imageField.Image = iTextSharp.text.Image.GetInstance(Path.GetDirectoryName(srcPath) + "/HONGZHANG.png");
                    imageField.ScaleIcon = PushbuttonField.SCALE_ICON_ALWAYS;
                    imageField.ProportionalIcon = false;
                    imageField.Options = BaseField.READ_ONLY;

                    pdfStamper.AcroFields.RemoveField("HONGZHANG");
                    pdfStamper.AddAnnotation(imageField.Field, fieldPosition.page);
                    #endregion
                }
                
                #endregion

                pdfStamper.FormFlattening = true;
                pdfStamper.Close();
                pdfReader.Close();
                fs.Close();

                #region 加密
                DateStrat(targetPath + ".tmp", targetPath, ds.Tables[2].Rows[0]["PWD"].ToString());
                #endregion
            }
            catch (Exception ex)
            {
                LogUtil.Error("电子合同生成发生异常：{0}", ex);
                throw ex;
            }

            ////string[] _png = Directory.GetFiles(@"C:\Users\Administrator\Desktop\wtb\电子合同\浦威CSMS\单位-变更\单张");
            ////process(_png, @"C:\Users\Administrator\Desktop\wtb\电子合同\浦威CSMS\PDF\浦东威立雅-单位用水合同.pdf");
            return "";// "http://" + Request.Url.Authority.ToString() + Request.ApplicationPath + "/PDFFILE/" + filename;
        }

        /// <summary>
        /// 联合过户-合同填充
        /// </summary>
        /// <param name="srcPath"></param>
        /// <param name="targetPath"></param>
        /// <param name="imgPath"></param>
        /// <param name="password"></param>
        /// <param name="ds"></param>
        /// <returns></returns>
        public string WritePDF1(string srcPath, string targetPath,string imgPath, string password, DataSet ds)
        {
            try
            {
                BaseFont baseFont = BaseFont.CreateFont("C:\\Windows\\Fonts\\simhei.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);//获取系统的字体
                BaseFont baseFontk = BaseFont.CreateFont("C:\\Windows\\Fonts\\simkai.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                iTextSharp.text.Font font2 = new iTextSharp.text.Font(baseFont, 11);//字体样式

                PdfReader pdfReader = new PdfReader(srcPath);//读取pdf
                PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(targetPath+".tmp", FileMode.Create, FileAccess.Write, FileShare.None));//新文件设置

                #region 填充
                //字段
                foreach (DataRow item_col in ds.Tables[1].Rows)
                {
                    
                    string pdf_name = item_col["PDF_COLUMNNAME"].ToString();//pdf字段
                    string data_columnname = item_col["DATA_COLUMNNAME"].ToString();//数据字段
                    if (pdf_name != "NULL")
                    {
                        int pagenum = Convert.ToInt32(pdf_name.Split(',')[0]);//pdf页数
                        int x = Convert.ToInt32(pdf_name.Split(',')[1]);//X
                        int y = Convert.ToInt32(pdf_name.Split(',')[2]);//Y
                        PdfContentByte over = pdfStamper.GetOverContent(pagenum);//pdf页数

                        if (data_columnname != "<IMG>")//非图片类型
                        {
                            string value = ds.Tables[2].Rows[0][data_columnname] == DBNull.Value ? "" : ds.Tables[2].Rows[0][data_columnname].ToString();//值
                            Phrase _Phrase = new Phrase(value, font2);
                            ColumnText.ShowTextAligned(over, Element.ALIGN_CENTER, _Phrase, x, y, 0);//填充
                        }
                        else//图片
                        {
                            int width = Convert.ToInt32(pdf_name.Split(',')[3]);//X
                            int height = Convert.ToInt32(pdf_name.Split(',')[4]);//Y
                            #region 图片赋值
                            iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(imgPath);
                            img.ScaleAbsolute(width, height);//图片大小
                            img.SetAbsolutePosition(x, y);//图片定位
                            over.AddImage(img);
                            #endregion
                        }
                    }
                }
                #endregion

                pdfStamper.Close();

                #region 加密
                DateStrat(targetPath + ".tmp", targetPath, ds.Tables[2].Rows[0]["PWD"].ToString());
                #endregion
            }
            catch (Exception ex)
            {
                LogUtil.Error("联合过户合同生成发生错误:{0}", ex.Message);
                throw ex;
            }
            return "";
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="src">源文件（未加密）</param>
        /// <param name="dest">目标文件</param>
        /// <param name="pws">密码</param>
        public void DateStrat(string src, string dest,string pws)
        {
            try
            {
                if (string.IsNullOrEmpty(src) || string.IsNullOrEmpty(dest))
                {
                    LogUtil.Error("源文件或目标文件为空");
                    return;
                }
                PdfReader reader = new PdfReader(src); //读取要加密的PDF文件
                int n = reader.NumberOfPages;     //获取PDF文件的页数
                iTextSharp.text.Rectangle pagesize = reader.GetPageSize(1);
                Document document = new Document(pagesize);
                FileStream stream = new FileStream(dest, FileMode.Create);
                PdfCopy copy = new PdfCopy(document, stream);
                copy.SetEncryption(PdfWriter.STRENGTH128BITS, pws, null, PdfWriter.AllowCopy | PdfWriter.AllowPrinting);
                //加密必须放在文档打开之前
                document.Open();
                //写文件
                for (int i = 1; i <= n; i++)
                {
                    PdfImportedPage page = copy.GetImportedPage(reader, i);
                    copy.AddPage(page);
                }
                document.Close();
                reader.Close();
                stream.Close();
            }
            catch (Exception ex)
            {
                LogUtil.Error("合同文件加密发生异常{0}", ex.Message);
            }
        }
        /// <summary>
        /// 生成本地电子合同PDF
        /// </summary>
        /// <param name="incident_id"></param>
        /// <returns></returns>
        public bool CreateLocalPDF(string incident_id,out string localfilename,out string msg)
        {
            //string[] _png = Directory.GetFiles(@"C:\Users\Administrator\Desktop\wtb\电子合同\浦威CSMS\单位-变更\new");
            
            //process(_png, @"C:\Users\Administrator\Desktop\wtb\电子合同\浦威CSMS\PDF\浦东威立雅-单位用水合同1.pdf");

            AccessDataBase _AccessDataBase = new AccessDataBase();
            bool _result = false;
            DataSet ds = _AccessDataBase.QueryHeTongXX(incident_id);
            
            
            if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() != "00|")
            {
                msg = ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1];
                LogUtil.Info("申请单ID：{0}，{1}", incident_id, msg);
                localfilename = "";
                return false;
            }
            if (ds.Tables[1].Rows[0]["BUSINESSTYPE"].ToString() != "26")
            {
                #region 一网通办过户及实名制
                string cid = ds.Tables[2].Rows[0]["S_CID"].ToString();
                string pwd = ds.Tables[2].Rows[0]["PWD"].ToString();
                string dic = ds.Tables[2].Rows[0]["FOLDERNAME"].ToString();
                string _muban = ConfigurationManager.AppSettings["HETONGPATH_OLD"] + "\\" + ds.Tables[2].Rows[0]["MB_FILENAME"].ToString();
                string _hetong = ConfigurationManager.AppSettings["HETONGPATH_NEW"];
                try
                {
                    localfilename = _hetong + "/" + dic + "/" + cid + ".pdf";
                    if (!Directory.Exists(_hetong + "/" + dic)) Directory.CreateDirectory(_hetong + "/" + dic);
                    this.WritePDF(_muban, localfilename, pwd, ds);
                    msg = "";
                    _result = true;
                }
                catch (Exception ex)
                {
                    LogUtil.Info("申请单ID：{0}，发生异常：{1}", incident_id, ex.Message);
                    localfilename = "";
                    msg = "接口发生异常";
                    _result = false;
                }
                return _result;
                #endregion
            }
            else
            {
                #region 联合过户
                
                string cid = ds.Tables[2].Rows[0]["S_CID"].ToString();
                string pwd = ds.Tables[2].Rows[0]["PWD"].ToString();
                string dic = ds.Tables[2].Rows[0]["FOLDERNAME"].ToString();
                string _hetong = ConfigurationManager.AppSettings["HETONGPATH_NEW"];
                string _muban = ConfigurationManager.AppSettings["LocalMediaFiles"] + "\\" + dic +"\\"+ ds.Tables[2].Rows[0]["MB_FILENAME"].ToString();
                try
                {
                    localfilename = _hetong + "/" + dic + "/" + cid + ".pdf";
                    if (!Directory.Exists(_hetong + "/" + dic)) Directory.CreateDirectory(_hetong + "/" + dic);
                    this.WritePDF1(_muban, localfilename, ConfigurationManager.AppSettings["HETONGPATH_OLD"] + "\\HONGZHANG.png", pwd, ds);
                    msg = "";
                    _result = true;
                }
                catch (Exception ex)
                {
                    LogUtil.Info("申请单ID：{0}，发生异常：{1}", incident_id, ex.Message);
                    localfilename = "";
                    msg = "接口发生异常"+ex.Message;
                    _result = false;
                }
                return _result;
                #endregion
            }
        }

        /// <summary>
        /// 生成本地电子合同PDF
        /// </summary>
        /// <param name="incident_id"></param>
        /// <returns></returns>
        public string CreateLocalPDFLOCAL(string V_S_CID, string V_S_HETONGBH, string V_S_HM, string V_S_JH, string V_D_DIANHUA, string V_S_ZHENGJIANID, out string filename, out string msg)
        {          
            AccessDataBase _AccessDataBase = new AccessDataBase();
            string _result = "";
            DataSet ds = _AccessDataBase.CAQueryHeTongXX(V_S_CID, V_S_HETONGBH, V_S_HM, V_S_JH, V_D_DIANHUA, V_S_ZHENGJIANID);
            string cid = ds.Tables[2].Rows[0]["S_CID"].ToString();
            string _muban = ConfigurationManager.AppSettings["HETONGPATH_OLD"] + "\\" + ds.Tables[2].Rows[0]["MB_FILENAME"].ToString();
            string _hetong = ConfigurationManager.AppSettings["HETONGPATH_NEW"];
            string dic = ds.Tables[2].Rows[0]["FOLDERNAME"].ToString();
            try
            {
                string localfilename = _hetong + "/" + dic + "/" + V_S_HETONGBH + ".pdf";
                if (!Directory.Exists(_hetong + "/" + dic)) Directory.CreateDirectory(_hetong + "/" + dic);
                this.WritePDFNOPW(_muban, localfilename, ds);
                byte[] PDFBYTES = File.ReadAllBytes(localfilename);
                msg = "";
                string BASE64PDF = Convert.ToBase64String(PDFBYTES);
                _result = BASE64PDF;
                filename = V_S_HETONGBH + ".pdf";
                //bool result = UploadFile2CSMS(dic, localfilename);
  

                
                List<FormItemModel> lstPara = new List<FormItemModel>();

                FormItemModel model = new FormItemModel();
                model.Key = "file";
                model.FileName = filename;
                model.FileContent = FileToStream(localfilename);//FormRequest.FileToStream("文件路径");
                lstPara.Add(model);          

                model = new FormItemModel();
                model.Key = "filename";
                model.Value = filename;
                lstPara.Add(model);

                model = new FormItemModel();
                model.Key = "code";
                model.Value = "090";
                lstPara.Add(model);
                //string strResult = FormRequest.PostForm("http://10.95.11.20:8122/management/ca/ca/upload", lstPara);
                string strResult = FormRequest.PostForm("http://180.167.190.84:30074/management/ca/ca/upload", lstPara);
                return strResult;
            }
            catch (Exception ex)
            {
                LogUtil.Info("申请单ID：{0}，发生异常：{1}", V_S_CID, ex.Message);
                filename = "";
                msg = "接口发生异常";
                _result = "";
            }
            return _result;
        }
        /// <summary>
        /// 填充PDF模版
        /// </summary>
        /// <param name="srcPath">模版文件path，例如：../PDFFILE/城投水务二联一户多人口协议模板.pdf;</param>
        /// <param name="targetPath">新文件存放位置：例如：../PDFFILE/城投水务二联一户多人口协议20200628.pdf;</param>
        /// <param name="ds">table0 填充字段，table1 数据区域</param>
        /// <returns></returns>
        public string WritePDFNOPW(string srcPath, string targetPath, DataSet ds)
        {
            try
            {
                PdfReader pdfReader = new PdfReader(srcPath);
                FileStream fs = new FileStream(targetPath , FileMode.Create);
                PdfStamper pdfStamper = new PdfStamper(pdfReader, fs);
                AcroFields pdfFormFields = pdfStamper.AcroFields;
                BaseFont bf = BaseFont.CreateFont("C:\\Windows\\Fonts\\SimHei.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); //用系统中的字体文件SimHei.ttf创建文件字体  

                pdfFormFields.AddSubstitutionFont(bf);

                #region 填充域
                foreach (DataRow item_col in ds.Tables[1].Rows)
                {
                    string pdf_name = item_col["PDF_COLUMNNAME"].ToString();//pdf字段
                    string data_columnname = item_col["DATA_COLUMNNAME"].ToString();//数据字段
                    if (pdf_name != "NULL")
                    {
                        string value = ds.Tables[2].Rows[0][data_columnname] == DBNull.Value ? "" : ds.Tables[2].Rows[0][data_columnname].ToString();//值

                        //要输入中文就要设置域的字体;
                        pdfFormFields.SetFieldProperty(pdf_name, "textfont", bf, null);
                        pdfFormFields.SetField(pdf_name, value);
                    }
                }
                pdfStamper.FormFlattening = true;
                pdfStamper.Close();
                pdfReader.Close();
                fs.Close();
                #endregion
            }
            catch (Exception ex)
            {
                LogUtil.Error("电子合同生成发生异常：{0}", ex);
                throw ex;
            }
            return "";
        }
        /// <summary>
        /// 获取文件到本地
        /// </summary>
        /// <param name="FileName"></param>
        public string getFiles(string INCIDENT_ID, string FileName)
        {
            //下载文件
            string LocalMediaFiles = ConfigurationManager.AppSettings["LocalMediaFiles"] + "\\download";
            FtpWeb _ftp = new FtpWeb(ConfigurationManager.AppSettings["FTP_IP"], ConfigurationManager.AppSettings["FTP_PATH"], ConfigurationManager.AppSettings["FTP_ACCOUNT"], ConfigurationManager.AppSettings["FTP_PWS"]);
            //_ftp.Download(LocalMediaFiles + "\\" + INCIDENT_ID, FileName);
            LogUtil.Info(ConfigurationManager.AppSettings["FTP_IP"] + ";" + "16022" + ";" + ConfigurationManager.AppSettings["FTP_ACCOUNT"] + ";" + ConfigurationManager.AppSettings["FTP_PWD"] + ";/"+ConfigurationManager.AppSettings["FTP_PATH"] + "/" + INCIDENT_ID + "/" + FileName + ";" + ConfigurationManager.AppSettings["LocalMediaFiles"] + "\\download" + ";" + FileName);
            _ftp.SFTPOperation(ConfigurationManager.AppSettings["FTP_IP"], "16022", ConfigurationManager.AppSettings["FTP_ACCOUNT"], ConfigurationManager.AppSettings["FTP_PWD"]);
            _ftp.DownloadSFTP("/"+ConfigurationManager.AppSettings["FTP_PATH"] + "/" + INCIDENT_ID + "/" + FileName, ConfigurationManager.AppSettings["LocalMediaFiles"] + "\\download", FileName);
            return LocalMediaFiles + "\\" + FileName;
        }

        #region 类型词语
        
        
        public string getBusinessType(string incident_type)
        {
            string v_BusinessType = "";
            switch (incident_type)
            {
                case "McsItemType.ResidentApply":
                    v_BusinessType = "01";
                    break;
                case "McsItemType.CompanyApply":
                    v_BusinessType = "02";
                    break;
                case "McsItemType.InquiryPayment":
                    v_BusinessType = "03";
                    break;
                case "McsItemType.RepairLeakWaterResident":
                    v_BusinessType = "04";
                    break;
                case "McsItemType.RepairLeakWaterCompany":
                    v_BusinessType = "05";
                    break;
                case "McsItemType.RepairUseWaterResident":
                    v_BusinessType = "06";
                    break;
                case "McsItemType.RepairUseWaterCompany":
                    v_BusinessType = "07";
                    break;
                case "McsItemType.RepairWaterQualityResident":
                    v_BusinessType = "08";
                    break;
                case "McsItemType.RepairWaterQualityCompany":
                    v_BusinessType = "09";
                    break;
                case "McsItemType.RepairWaterMeterResident":
                    v_BusinessType = "10";
                    break;
                case "McsItemType.RepairWaterMeterCompany":
                    v_BusinessType = "11";
                    break;
                case "McsItemType.RepairOtherResidentCompany":
                    v_BusinessType = "12";
                    break;
                case "McsItemType.RepairOtherCompany":
                    v_BusinessType = "13";
                    break;
                case "McsItemType.RepairResidentTransfer":
                    v_BusinessType = "14";
                    break;
                case "McsItemType.RepairCompanyTransfer":
                    v_BusinessType = "15";
                    break;
                case "McsItemType.RepairWatermeterSplit":
                    v_BusinessType = "16";
                    break;
                case "McsItemType.RealNameRegiste":
                    v_BusinessType = "17";
                    break;
                //case "McsItemType.RepairMeterOutward":
                //case "McsItemType.RepairUnseal":
                //    v_BusinessType = "10";
                //    break;//
                //case "McsItemType.WriteOffAccount"://	水表拆表销户
                //    v_BusinessType = "10";
                //    break;
                //case "McsItemType.CustomerInfoChange"://	客户信息变更
                //case "McsItemType.UseWaterNatureChange"://	用水性质变更
                //case "McsItemType.WaterRateCollection"://	水费托收
                //case "McsItemType.ElecInvoiceAutoPush"://	电子发票自动推送
                //case "McsItemType.ElecInvoiceObtain"://	电子发票获取（单次）
                //case "McsItemType.PayNoticeRemail"://	补(寄)缴费通知单
                case "McsItemType.MultiHousehold"://	居民一户多人口（含续签)
                    v_BusinessType = "25";
                    break;
                //case "McsItemType.SharingWaterMeter"://	居民合用表
                //case "McsItemType.AdviceComplaint"://	业务咨询、表扬、投诉、建议"
                //    v_BusinessType = "NULL";
                //    break;
                case "McsItemType.UniTransfer"://	居民联合过户
                    v_BusinessType = "26";
                    break;
                default:
                    v_BusinessType = incident_type;
                    break;
            }
            return v_BusinessType;
        }

        public string getZhengJianLX(string cert_type,out string zhengjianmc)
        {
            string zhengjianlx = "";
            switch (cert_type)
            {
                case "111":
                case "112":
                    zhengjianlx = "0";//身份证
                    zhengjianmc = "身份证";
                    break;
                case "411":
                case "412":
                case "413":
                case "414":
                    zhengjianlx = "1";//护照
                    zhengjianmc = "护照";
                    break;
                case "03":
                    zhengjianlx = "3";//工商登记号
                    zhengjianmc = "工商登记号";
                    break;
                case "02":
                    zhengjianlx = "4";//组织机构代码
                    zhengjianmc = "组织机构代码";
                    break;
                case "114":
                case "115":
                case "118":
                case "119":
                    zhengjianlx = "5";//军官证
                    zhengjianmc = "军官证";
                    break;
                case "04":
                    zhengjianlx = "6";//事业单位法人证书
                    zhengjianmc = "事业单位法人证书";
                    break;
                //case "":
                //    zhengjianlx = "7";//医疗机构执业许可证
                //    break;
                //case "02":
                //    zhengjianlx = "8";//民办非企业单位登记证书
                //    break;
                case "01":
                    zhengjianlx = "9";//统一社会信用代码
                    zhengjianmc = "统一社会信用代码";
                    break;
                
                default:
                    zhengjianlx = "";//
                    zhengjianmc = "其他证件";
                    break;
            }

            return zhengjianlx;
        }
        #endregion
        #region webapi表单方式调用 (old)
        // https
        //private static readonly string DefaultUserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
 
        //private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
        //{
        //    return true; //总是接受     
        //}

        
        ///// <summary>  
        ///// 使用Post方法获取字符串结果  
        ///// </summary>  
        ///// <param name="url"></param>  
        ///// <param name="formItems">Post表单内容</param>  
        ///// <param name="cookieContainer"></param>  
        ///// <param name="timeOut">默认20秒</param>  
        ///// <param name="encoding">响应内容的编码类型（默认utf-8）</param>  
        ///// <returns></returns>  
        //public static string PostForm(string url, repairFile _repairFile, CookieContainer cookieContainer = null, string refererUrl = null, Encoding encoding = null, int timeOut = 20000)
        //{
        //    HttpWebRequest request = null;
        //    //HTTPSQ请求  
        //    if (url.Substring(0, 8) == "https://")
        //    {
        //        ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
        //    }

        //    request = WebRequest.Create(url) as HttpWebRequest;
        //    request.ProtocolVersion = HttpVersion.Version10;
        //    #region 初始化请求对象
        //    request.Method = "POST";
        //    request.Timeout = timeOut;
        //    //request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
        //    request.KeepAlive = true;
        //    //request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36";
        //    if (!string.IsNullOrEmpty(refererUrl))
        //        request.Referer = refererUrl;
        //    if (cookieContainer != null)
        //        request.CookieContainer = cookieContainer;
        //    #endregion

        //    string boundary = "----" + DateTime.Now.Ticks.ToString("x");//分隔符  
        //    request.ContentType = string.Format("multipart/form-data; boundary={0}", boundary);
        //    //请求流  
        //    var postStream = new MemoryStream();
        //    #region 处理Form表单请求内容
        //    //是否用Form上传文件  
        //    var formUploadFile = true;
        //    if (formUploadFile)
        //    {
        //        //文件数据模板  
        //        string fileFormdataTemplate =
        //            "\r\n--" + boundary +
        //            "\r\nContent-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"" +
        //            "\r\nContent-Type: multipart/form-data" +
        //            "\r\n\r\n";
        //        //文本数据模板  
        //        string dataFormdataTemplate =
        //            "\r\n--" + boundary +
        //            "\r\nContent-Disposition: form-data; name=\"{0}\"" +
        //            "\r\n\r\n{1}";
        //        foreach (var item in _repairFile.GetType().GetProperties())
        //        {
                    
        //            string formdata = null;
        //            if (item.PropertyType==typeof(Stream))
        //            {
        //                //上传文件  
        //                formdata = string.Format(
        //                    fileFormdataTemplate,
        //                    item.Name, //表单键
        //                    GetPropertyValue(_repairFile,"filename"));
        //            }
        //            else
        //            {
        //                //上传文本  
        //                formdata = string.Format(
        //                    dataFormdataTemplate,
        //                    item.Name,
        //                    GetPropertyValue(_repairFile, item.Name));
        //            }

        //            //统一处理  
        //            byte[] formdataBytes = null;
        //            //第一行不需要换行  
        //            if (postStream.Length == 0)
        //                formdataBytes = Encoding.UTF8.GetBytes(formdata.Substring(2, formdata.Length - 2));
        //            else
        //                formdataBytes = Encoding.UTF8.GetBytes(formdata);
        //            postStream.Write(formdataBytes, 0, formdataBytes.Length);

        //            //写入文件内容  
        //            if (item.FileContent != null && item.FileContent.Length > 0)
        //            {
        //                using (var stream = item.FileContent)
        //                {
        //                    byte[] buffer = new byte[1024];
        //                    int bytesRead = 0;
        //                    while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) != 0)
        //                    {
        //                        postStream.Write(buffer, 0, bytesRead);
        //                    }
        //                }
        //            }
        //        }
        //        //结尾  
        //        var footer = Encoding.UTF8.GetBytes("\r\n--" + boundary + "--\r\n");
        //        postStream.Write(footer, 0, footer.Length);

        //    }
        //    else
        //    {
        //        request.ContentType = "application/json;charset=UTF-8";
        //    }
        //    #endregion

        //    request.ContentLength = postStream.Length;

        //    #region 输入二进制流
        //    if (postStream != null)
        //    {
        //        postStream.Position = 0;
        //        //直接写入流  
        //        Stream requestStream = request.GetRequestStream();

        //        byte[] buffer = new byte[1024];
        //        int bytesRead = 0;
        //        while ((bytesRead = postStream.Read(buffer, 0, buffer.Length)) != 0)
        //        {
        //            requestStream.Write(buffer, 0, bytesRead);
        //        }

        //        ////debug  
        //        //postStream.Seek(0, SeekOrigin.Begin);  
        //        //StreamReader sr = new StreamReader(postStream);  
        //        //var postStr = sr.ReadToEnd();  
        //        postStream.Close();//关闭文件访问  
        //    }
        //    #endregion

        //    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        //    if (cookieContainer != null)
        //    {
        //        response.Cookies = cookieContainer.GetCookies(response.ResponseUri);
        //    }

        //    using (Stream responseStream = response.GetResponseStream())
        //    {
        //        using (StreamReader myStreamReader = new StreamReader(responseStream, encoding ?? Encoding.UTF8))
        //        {
        //            string retString = myStreamReader.ReadToEnd();
        //            return retString;
        //        }
        //    }

        //}
        #endregion

        #region webapi表单方式调用 (new)
        public string postFile(repairFile _repairFile,string _url)
        {
            List<FormItemModel> lstPara = new List<FormItemModel>();

            FormItemModel model = new FormItemModel();
            model.Key = "file";
            model.FileName = _repairFile.filename;
            model.FileContent = _repairFile.File;//FormRequest.FileToStream("文件路径");
            lstPara.Add(model);

            model = new FormItemModel();
            model.Key = "third_id";
            model.Value = _repairFile.third_id;
            lstPara.Add(model);

            model = new FormItemModel();
            model.Key = "cert_type";
            model.Value = _repairFile.cert_type;
            lstPara.Add(model);

            model = new FormItemModel();
            model.Key = "cert_source";
            model.Value = _repairFile.cert_source;
            lstPara.Add(model);

            model = new FormItemModel();
            model.Key = "cert_number";
            model.Value = _repairFile.cert_number;
            lstPara.Add(model);

            model = new FormItemModel();
            model.Key = "file_uuid";
            model.Value = _repairFile.file_uuid;
            lstPara.Add(model);

            model = new FormItemModel();
            model.Key = "filename";
            model.Value = _repairFile.filename;
            lstPara.Add(model);

            string strResult = FormRequest.PostForm(_url, lstPara);
            return strResult;
        }
        #endregion
        /// <summary>
        /// 获取一个类指定的属性值
        /// </summary>
        /// <param name="info">object对象</param>
        /// <param name="field">属性名称</param>
        /// <returns>属性值</returns>
        private static object GetPropertyValue(object info, string field)
        {
            if (info == null) return null;
            Type t = info.GetType();
            IEnumerable<System.Reflection.PropertyInfo> property = from pi in t.GetProperties() where pi.Name.ToLower() == field.ToLower() select pi;
            return property.First().GetValue(info, null);
        }
        /// <summary>
        /// 年月格式校验
        /// </summary>
        /// <param name="v_ny"></param>
        /// <param name="v_mc"></param>
        /// <returns></returns>
        public string yearAndMonthPanDuan(string v_ny, string v_mc)
        {
            Regex regex = new Regex(@"^(-)?\d+(\.\d+)?$");
            string msgstr = "00|";
            if (!regex.IsMatch(v_ny))
            {
                msgstr = "04|" + v_mc + "格式不正确！";
            }
            if (msgstr == "00|" && v_ny.Trim().Length > 6)
            {
                msgstr = "05|" + v_mc + "年月位数不正确！";
            }
            return msgstr;
        }

        /// <summary>
        /// SFTP文件上传，暂用于供水合同
        /// </summary>
        /// <param name="localfilepath"></param>
        /// <param name="localfilenames"></param>
        /// <param name="ftpfilepath"></param>
        /// <param name="outerroinfo"></param>
        /// <returns></returns>
        public bool sftp_upload(string localfilepath, string[] localfilenames, string ftpfilepath, out string outerroinfo)
        {
            //Renci.SshNet.SftpClient _sft = new Renci.SshNet.SftpClient("", "", "", "");

            string ip = ConfigurationManager.AppSettings["SFTP_IP"];
            string uid = ConfigurationManager.AppSettings["SFTP_ACCOUNT"];
            string pws = ConfigurationManager.AppSettings["SFTP_PWD"];
            int port = Convert.ToInt32(ConfigurationManager.AppSettings["SFTP_PORT"]);
            bool _result = false;
            try
            {
                LogUtil.Info("ip={0},uid={1}, port={2},localfilepath={3}, localfilenames={4}, ftpfilepath={5}", ip, uid, port, localfilepath, localfilenames, ftpfilepath);
                SH3H.CSM.FTP.NetSFTP _sftp = new NetSFTP(ip, uid, pws, port);
                if (!_sftp.DirectoryInfoIsExists(ftpfilepath)) _sftp.CreateDirectory(ftpfilepath);//创建文件夹目录
                _result = _sftp.UpLoadListFile(localfilepath, localfilenames,ftpfilepath, out outerroinfo);
                
            }
            catch (Exception ex)
            {
                _result = false;
                outerroinfo = ex.Message;
                LogUtil.Error("SFTP上传文件发生异常{0}", ex.Message);
            }
            
            return _result;
        }

        private void process(string[] files, string newpdf)
        {
            iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 25, 25, 25, 25);

            try
            {
                iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(newpdf, FileMode.Create, FileAccess.ReadWrite));

                document.Open();
                iTextSharp.text.Image image;
                for (int i = 0; i < files.Length; i++)
                {
                    if (String.IsNullOrEmpty(files[i])) break;

                    image = iTextSharp.text.Image.GetInstance(files[i]);

                    if (image.Height > iTextSharp.text.PageSize.A4.Height - 25)
                    {
                        image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
                    }
                    else if (image.Width > iTextSharp.text.PageSize.A4.Width - 25)
                    {
                        image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
                    }
                    
                    image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
                    //image.SetDpi(72, 72);

                    document.NewPage();
                    document.Add(image);

                }
            }
            catch (Exception ex)
            {
                LogUtil.Error("{0}", ex.Message);
            }
            document.Close();
        }
        public void getFilesnew(string localfilename)
        {

            FtpWeb _ftpweb = new FtpWeb(ConfigurationManager.AppSettings["SFTP_IP"], ConfigurationManager.AppSettings["SFTP_PATH"], ConfigurationManager.AppSettings["SFTP_ACCOUNT"], ConfigurationManager.AppSettings["SFTP_PWD"]);
            string[] str1 = System.IO.Path.GetDirectoryName(localfilename).ToString().Split('\\');
            _ftpweb.SFTPOperation(ConfigurationManager.AppSettings["FTP_IP"], "16022", ConfigurationManager.AppSettings["SFTP_ACCOUNT"], ConfigurationManager.AppSettings["SFTP_PWD"]);

            LogUtil.Info("ftpURI:{0}", _ftpweb.ftpURI);
            LogUtil.Info("str1:{0}", str1);
            LogUtil.Info("localfilename:{0}", localfilename);
            LogUtil.Info("SFTP_PATH:{0}", ConfigurationManager.AppSettings["SFTP_PATH"]);
            _ftpweb.Put(localfilename, ConfigurationManager.AppSettings["SFTP_PATH"] + "/" + str1[str1.Length - 1].ToString(), System.IO.Path.GetFileName(localfilename));

        }
        #region 新合同生成 ADD20221020
        /// <summary>
        /// 生成本地电子合同PDF
        /// </summary>
        /// <param name="incident_id"></param>
        /// <returns></returns>
        public bool CreateLocalPDFN(string incident_id, out string localfilename, out string msg, out string year, out string month, out string incident_type, out string apply_no)
        {
            apply_no = null;
            //string[] _png = Directory.GetFiles(@"C:\Users\Administrator\Desktop\wtb\电子合同\浦威CSMS\单位-变更\new");

            //process(_png, @"C:\Users\Administrator\Desktop\wtb\电子合同\浦威CSMS\PDF\浦东威立雅-单位用水合同1.pdf");

            AccessDataBase _AccessDataBase = new AccessDataBase();
            bool _result = false;
            DataSet ds = _AccessDataBase.QueryHeTongXX(incident_id);


            if (ds.Tables[0].Rows[0]["MSGCODE"].ToString() != "00|")
            {
                msg = ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1];
                LogUtil.Info("申请单ID：{0}，{1}", incident_id, msg);
                localfilename = "";
                year = "";
                month = "";
                incident_type = "";
                return false;
            }
            if (ds.Tables.Count != 3)
            {
                LogUtil.Info("查询WTB_QUERYHETONGXX存储过程出现异常:{0},[1]", ds.Tables[0].Rows[0]["MSGCODE"].ToString(), incident_id);
                msg = ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1];
                localfilename = "";
                year = "";
                month = "";
                incident_type = "";
                return false;
            }
            #region 文件生成新方法
            string jmpanduan = ",14,17,19,26,30,";
            string dwpanduan = ",15,18,20,";
            string BUSINESSTYPE = ds.Tables[2].Rows[0]["BUSINESSTYPE"].ToString();
            string jmdw = ""; //0 是居民 1是单位
            string BUSINESSTYPEZ = "," + BUSINESSTYPE + ",";
            int jieguo = jmpanduan.IndexOf(BUSINESSTYPEZ);
            int jiguo2 = dwpanduan.IndexOf(BUSINESSTYPEZ);
            if (jmpanduan.IndexOf(BUSINESSTYPEZ) != -1)
            {
                jmdw = "0";
            }
            else if (dwpanduan.IndexOf(BUSINESSTYPEZ) != -1)
            {
                jmdw = "1";
            }
            else
            {
                LogUtil.Info("BUSINESSTYPE不是居民和单位的:{0},[1],{2}", ds.Tables[0].Rows[0]["MSGCODE"].ToString(), incident_id, BUSINESSTYPE);
                msg = ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1];
                localfilename = "";
                year = "";
                month = "";
                incident_type = "";
                return false;
            }
            year = ds.Tables[2].Rows[0]["YEAR"].ToString(); 
            month = ds.Tables[2].Rows[0]["MONTH"].ToString(); 
            incident_type = ds.Tables[2].Rows[0]["INCIDENT_TYPE"].ToString(); 
            string cid = ds.Tables[2].Rows[0]["S_CID"].ToString();
            string pwd = ds.Tables[2].Rows[0]["PWD"].ToString();
            string dic = ds.Tables[2].Rows[0]["FOLDERNAME"].ToString();
            if (ds.Tables[2].Columns.Contains("APPLY_NO")) 
            {
                apply_no = ds.Tables[2].Rows[0]["APPLY_NO"].ToString();
            }

            string _muban = ConfigurationManager.AppSettings["HETONGPATH_OLD"];
            //+ "\\" + incident_id+".pdf";
            string _hetong = ConfigurationManager.AppSettings["HETONGPATH_NEW"];
            try
            {
                localfilename = _hetong + "/" + dic + "/" + cid + ".pdf";
                if (!Directory.Exists(_hetong + "/" + dic)) Directory.CreateDirectory(_hetong + "/" + dic);
                string rr = this.GeneratePDF(_muban, localfilename, pwd, ds, jmdw, incident_id);
                msg = "";
                if (rr == "1")
                {
                    _result = true;
                }
                else
                {
                    _result = false;
                }


            }
            catch (Exception ex)
            {
                LogUtil.Info("申请单ID：{0}，发生异常：{1}", incident_id, ex.Message);
                localfilename = "";
                msg = "接口发生异常";
                _result = false;
            }
            msg = ds.Tables[0].Rows[0]["MSGCODE"].ToString().Split('|')[1];
            //localfilename = "";
            return _result;
            #endregion
        }
        /// <summary>
        /// 接口获取FTP印章合同
        /// </summary>
        /// <param name="srcPath">未加密合同地址</param>
        /// <param name="targetPath">加密合同地址</param>
        /// <param name="password">密码</param>
        /// <param name="ds"></param>
        /// <param name="dwjmtype">0：居民 1：单位</param>
        /// <returns></returns>
        public string GeneratePDF(string srcPath, string targetPath, string PDFpassword, DataSet ds, string dwjmtype, string incident_id)
        {
            return "";
            //try
            //{
            //    #region 模拟from-data请求数据
            //    HttpClient client = new HttpClient();
            //    #region 写死的参数
            //    string companyCode = ConfigurationManager.AppSettings["HT_companyCode"];
            //    string userId = ConfigurationManager.AppSettings["HT_userId"];
            //    string password = ConfigurationManager.AppSettings["HT_password"];
            //    string x = "";
            //    string y = "";
            //    string page = "";
            //    if (dwjmtype == "0")//居民
            //    {
            //        x = ConfigurationManager.AppSettings["HT_jmx"];
            //        y = ConfigurationManager.AppSettings["HT_jmy"];
            //        page = ConfigurationManager.AppSettings["HT_jmpage"];
            //    }
            //    else//单位
            //    {
            //        x = ConfigurationManager.AppSettings["HT_dwx"];
            //        y = ConfigurationManager.AppSettings["HT_dwy"];
            //        page = ConfigurationManager.AppSettings["HT_dwpage"];
            //    }

            //    #endregion
            //    string RequestToken = GetToken(companyCode, userId, password);//获取token 
            //    // string RequestToken = "12314124";
            //    client.DefaultRequestHeaders.Add("token", RequestToken);//加头
            //    var postContent = new MultipartFormDataContent();
            //    string inputData = companyCode;
            //    string inputData2 = incident_id;
            //    string inputData3 = x;
            //    string inputData4 = y;
            //    string inputData5 = page;

            //    postContent.Add(new StringContent(inputData), "companyCode");
            //    postContent.Add(new StringContent(inputData2), "incidentId");
            //    postContent.Add(new StringContent(inputData3), "x");
            //    postContent.Add(new StringContent(inputData4), "y");
            //    postContent.Add(new StringContent(inputData5), "page");      
            //    string URLrequest = System.Configuration.ConfigurationManager.AppSettings["HT_IP_REQUEST"].ToString();
            //    LogUtil.Error("生成文件参数" + inputData + "|" + inputData2 + "|" + inputData3 + "|" + inputData4 + "|" + inputData5 + "|" + URLrequest);
            //    //string URLrequest = "https://localhost:44304/Api/ZS/FormJS";

            //    HttpResponseMessage response = client.PostAsync(URLrequest, postContent).Result;
            //    LogUtil.Error("生成文件返回值" + response.Content.ReadAsStringAsync().Result);
            //    Receivedate JSdates = JsonConvert.DeserializeObject<Receivedate>(response.Content.ReadAsStringAsync().Result);
            //    //LogUtil.Info("接口获取的参数:{0}", response.Content.ReadAsStringAsync().Result);
            //    #endregion
            //    LogUtil.Error("生成文件位置" +srcPath+"|"+ incident_id + ".PDF");
            //    LogUtil.Error("生成文件位置内容" + JSdates.msg + "|" + JSdates.code + JSdates.data);

            //    string Branchofficersult = SaveDocument(JSdates.data, incident_id + ".PDF",srcPath);
            //    if (Branchofficersult == "error")
            //    {
            //        return "接口数据转化文件失败";
            //    }
            //    #region 加密
            //    PDFEncryption(srcPath + "\\" + incident_id + ".PDF", targetPath, PDFpassword);
            //    // DateStrat(targetPath + ".tmp", targetPath, ds.Tables[2].Rows[0]["PWD"].ToString());
            //    return "1";
            //    #endregion
            //}
            //catch (Exception ex)
            //{
            //    LogUtil.Error("电子合同生成发生异常：{0}", ex);
            //    throw ex;
            //}

            ////string[] _png = Directory.GetFiles(@"C:\Users\Administrator\Desktop\wtb\电子合同\浦威CSMS\单位-变更\单张");
            ////process(_png, @"C:\Users\Administrator\Desktop\wtb\电子合同\浦威CSMS\PDF\浦东威立雅-单位用水合同.pdf");
            return "";// "http://" + Request.Url.Authority.ToString() + Request.ApplicationPath + "/PDFFILE/" + filename;
        }
        /// <summary>
        /// PDF加密
        /// </summary>
        /// <param name="src">源文件（未加密）</param>
        /// <param name="dest">目标文件</param>
        /// <param name="pws">密码</param>
        public string PDFEncryption(string src, string dest, string pws)
        {
            try
            {
                if (string.IsNullOrEmpty(src) || string.IsNullOrEmpty(dest))
                {
                    return "源文件或目标文件为空";
                }
                PdfReader reader = new PdfReader(src); //读取要加密的PDF文件
                int n = reader.NumberOfPages;     //获取PDF文件的页数
                iTextSharp.text.Rectangle pagesize = reader.GetPageSize(1);
                Document document = new Document(pagesize);
                FileStream stream = new FileStream(dest, FileMode.Create);
                PdfCopy copy = new PdfCopy(document, stream);
                copy.SetEncryption(PdfWriter.STRENGTH128BITS, pws, null, PdfWriter.AllowCopy | PdfWriter.AllowPrinting);
                //加密必须放在文档打开之前
                document.Open();
                //写文件
                for (int i = 1; i <= n; i++)
                {
                    PdfImportedPage page = copy.GetImportedPage(reader, i);
                    copy.AddPage(page);
                }
                document.Close();
                reader.Close();
                stream.Close();
                return "1";
            }
            catch (Exception ex)
            {
                LogUtil.Error("电子合同加密发生异常：{0}", ex);
                return "合同文件加密发生异常:" + ex.Message;

            }
        }
        /// <summary>
        /// base64转PDF
        /// </summary>
        /// <param name="base64">base64字符</param>
        /// <param name="filename">文件名</param>
        /// <param name="filenamePath">文件路径</param>
        /// <returns></returns>
        public string SaveDocument(string base64, string filename, string filenamePath)
        {
            try
            {

                //string path = "~/Upload/";
                string sFilePath = filenamePath;
                string sFileName = filename /*"123." + "pdf"*/;   //这里的imageFormat就是文件类型
                sFileName = sFilePath + "\\" + sFileName;
                //路径不存在，则创建路径
                if (!Directory.Exists(sFilePath))
                {
                    Directory.CreateDirectory(sFilePath);
                }
                //如果文件已经存在，则删除文件
                if (System.IO.File.Exists(sFileName))
                {
                    System.IO.File.Delete(sFileName);
                }
                //注意：文件直接转base64前面会带有“data:application/pdf;base64,”前缀，需要去掉。
                byte[] DocBytes = Convert.FromBase64String(base64);
                //文件流创建文件内容
                FileStream fs = new FileStream(sFileName, FileMode.CreateNew);
                BinaryWriter bw = new BinaryWriter(fs);
                bw.Write(DocBytes, 0, DocBytes.Length);
                bw.Close();
                fs.Close();
                return "1";
            }
            catch (Exception ex)
            {
                //LogUtil.Error("SaveDocument生成发生异常：{0}", ex.Message);
                LogUtil.Error("SaveDocument生成发生异常：{0}, filename={1}, filenamePath={2}", ex.Message, filename, filenamePath);
                LogUtil.Error(ex.ToString());
                return "error";
            }
        }
        /// <summary>
        /// 获取token
        /// </summary>
        /// <param name="vcompany">公司名</param>
        /// <param name="vusername">账号</param>
        /// <param name="vpassword">密码</param>
        /// <returns></returns>
        public string GetToken(string vcompany, string vusername, string vpassword)
        {
            try
            {
                AccessDataBase _AccessDataBase = new AccessDataBase();
                DateTime sj = DateTime.Now;
                BranchOfficeGetTokenJson BGT = new BranchOfficeGetTokenJson
                {
                    companyCode = vcompany,
                    userId = sha256(vusername),
                    password = sha256(vpassword),
                    timestamp = getTimeStamp(sj).ToString()
                };
                var PostUrl = ConfigurationManager.AppSettings["TOKEN_IP_REQUEST"];//post请求                                                                                                //var PostUrl = "http://10.3.1.101:5070/company/getToken";
                #region aes key和iv
                var key = ConfigurationManager.AppSettings["TOKEN_IP_KEY"]; //KEY
                var iv = ConfigurationManager.AppSettings["TOKEN_IP_IV"];//iv
                byte[] Keybty = Encoding.UTF8.GetBytes(key);
                byte[] ivbty = Encoding.UTF8.GetBytes(iv);
                #endregion
                string sendData = JsonConvert.SerializeObject(BGT);
                RequestZH zh = new RequestZH()
                {
                    body = ToAesEncrypt(sendData, Keybty, ivbty)
                };
                string zhDate = JsonConvert.SerializeObject(zh);
                LogUtil.Info("GetToken请求的参数：{0}", zhDate);
                string resultData = QueryPostHttpsWebServiceJK(PostUrl, zhDate);
                //string resultData = PostJK(zhDate, PostUrl);
                LogUtil.Info("GetToken接收的参数：{0}", resultData);
                Receivedate JSdates = JsonConvert.DeserializeObject<Receivedate>(resultData);
                jsonToken jst = JsonConvert.DeserializeObject<jsonToken>(ToAesDecrypt(JSdates.data, Keybty, ivbty));
                return jst.token;// jiemi(JSdates.data);
            }
            catch (Exception ex)
            {
                LogUtil.Info("GetToken异常：{0}", ex.Message);
                return ex.Message;
            }
        }
        public string QueryPostHttpsWebServiceJK(String URL, string body)
        {
            //string rid = System.Guid.NewGuid().ToString();

            //string t = GetTimeStamp();
            LogUtil.Info("开始请求地址：" + URL);
            LogUtil.Info("请求参数：" + body);

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL);
            request.ProtocolVersion = HttpVersion.Version10;
            ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)3072;
            LogUtil.Info("协议版本：" + request.ProtocolVersion.ToString() + ";" + ServicePointManager.SecurityProtocol.ToString());
            ServicePointManager.ServerCertificateValidationCallback = new
RemoteCertificateValidationCallback
(
   delegate { return true; }
);



            ServicePointManager.CheckCertificateRevocationList = true;
            ServicePointManager.DefaultConnectionLimit = 1000;
            ServicePointManager.Expect100Continue = false;
            request.Method = "POST";
            //request.ContentType = "text/xml; charset=utf-8";
            //request.ContentType = "application/x-www-form-urlencoded";
            request.ContentType = "application/json";//charset=UTF-8
            Encoding encoding = Encoding.UTF8;
            /// 设置凭证与超时时间
            request.Credentials = CredentialCache.DefaultCredentials;
            request.KeepAlive = true;
            //request.ProtocolVersion = HttpVersion.Version11;
            request.Timeout = Convert.ToInt32(XIAODANTIMEOUT);//设置timeout 10S
            byte[] buffer = encoding.GetBytes(body);
            request.ContentLength = buffer.Length;
            request.GetRequestStream().Write(buffer, 0, buffer.Length);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
            {
                return reader.ReadToEnd();
            }
        }
        #region 时间戳
        /// <summary>
        /// 时间戳
        /// </summary>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        public static Int64 getTimeStamp(DateTime dateTime)
        {
            TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            return Convert.ToInt64(ts.TotalSeconds);
        }
        #endregion
        #region sha-256加密
        public string sha256(string data)
        {
            byte[] bytes = Encoding.UTF8.GetBytes(data);
            byte[] hash = SHA256Managed.Create().ComputeHash(bytes);
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < hash.Length; i++)
            {
                builder.Append(hash[i].ToString("x2"));
            }

            return builder.ToString();
        }
        #endregion
        #region AES
        //解密
        public static string ToAesDecrypt(string toDecrypt, byte[] keyArray, byte[] ivArray)
        {
            byte[] toEncryptArray = Convert.FromBase64String(toDecrypt);
            using (var rDel = new RijndaelManaged())
            {
                rDel.Key = keyArray;
                rDel.IV = ivArray;
                rDel.Mode = CipherMode.CBC;
                rDel.Padding = PaddingMode.PKCS7;
                var resultArray = rDel.CreateDecryptor().TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
                return Encoding.UTF8.GetString(resultArray);
            }
        }
        //加密
        public static string ToAesEncrypt(string toEncrypt, byte[] keyArray, byte[] ivArray)
        {
            byte[] toEncryptArray = Encoding.UTF8.GetBytes(toEncrypt);
            using (var rDel = new RijndaelManaged())
            {
                rDel.Key = keyArray;
                rDel.IV = ivArray;
                rDel.Mode = CipherMode.CBC;
                rDel.Padding = PaddingMode.PKCS7;
                var resultArray = rDel.CreateEncryptor().TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
                return Convert.ToBase64String(resultArray, 0, resultArray.Length);
            }
        }

        #endregion
        #region 接口请求方法(Post)
        /// <summary>
        /// http Post请求
        /// </summary>
        /// <param name="parameterData">参数</param>
        /// <param name="serviceUrl">访问地址</param>
        /// <param name="ContentType">默认 application/json , application/x-www-form-urlencoded,multipart/form-data,raw,binary </param>
        /// <param name="Accept">默认application/json</param>
        /// <returns></returns>
        public static string PostJK(string parameterData, string serviceUrl, string ContentType = "application/json", string Accept = "application/json")
        {

            //先根据用户请求的uri构造请求地址
            //string serviceUrl = string.Format("{0}/{1}", this.BaseUri, uri);

            //创建Web访问对象
            HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(serviceUrl);
            //把用户传过来的数据转成“UTF-8”的字节流
            byte[] buf = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(parameterData);

            myRequest.Method = "POST";
            //myRequest.Accept = "application/json";
            //myRequest.ContentType = "application/json";  // //Content-Type: application/x-www-form-urlencoded 
            myRequest.AutomaticDecompression = DecompressionMethods.GZip;
            myRequest.Accept = Accept;
            //myRequest.ContentType = ContentType;
            myRequest.ContentType = "application/json; charset=UTF-8";
            myRequest.ContentLength = buf.Length;
            myRequest.MaximumAutomaticRedirections = 1;
            myRequest.AllowAutoRedirect = true;

            //myRequest.Headers.Add("content-type", "application/json");
            //myRequest.Headers.Add("accept-encoding", "gzip");
            //myRequest.Headers.Add("accept-charset", "utf-8");

            //发送请求
            Stream stream = myRequest.GetRequestStream();
            stream.Write(buf, 0, buf.Length);
            stream.Close();

            //通过Web访问对象获取响应内容
            HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
            //通过响应内容流创建StreamReader对象，因为StreamReader更高级更快
            StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
            //string returnXml = HttpUtility.UrlDecode(reader.ReadToEnd());//如果有编码问题就用这个方法
            string returnData = reader.ReadToEnd();//利用StreamReader就可以从响应内容从头读到尾

            reader.Close();
            myResponse.Close();

            return returnData;
        }
        #endregion
        #region 定义类
        [Serializable]
        public class SealInput
        {
            public string v_incidentId { get; set; }
        }
        [Serializable]
        public class PassReference
        {
            public string vcompany { get; set; }
            public string vusername { get; set; }
            public string vpassword { get; set; }
        }
        [Serializable]
        public class BranchOfficeGetTokenJson
        {
            //分公司编码
            //非空， GSFGS,PDWLYZLS,SBBSZLS,PDXQZLS
            public string companyCode { get; set; }
            //账号
            public string userId { get; set; }
            //密码
            public string password { get; set; }
            // 当前请求时间，时间戳
            public string timestamp { get; set; }
        }
        [Serializable]
        public class RequestZH
        {
            public string body { get; set; }
        }
        [Serializable]
        public class Receivedate
        {
            public string requestId { get; set; }
            public string errCode { get; set; }
            public string errMessage { get; set; }
            public string success { get; set; }
            public string code { get; set; }
            public string data { get; set; }
            public string msg { get; set; }

        }
        [Serializable]
        public class jsonToken
        {
            public string token { get; set; }
        }
        #endregion
        #endregion

        #region 调用API Post请求接口测试方法1
        public HttpResult PostHttpNewWeb(string url, string paramStr, string token)
        {

            HttpResult r = new HttpResult();
            //string responseString = string.Empty;
            HttpWebRequest myRequest = null;
            HttpWebResponse myResponse = null;
            try
            {
                //JObject jobj = new JObject(new JProperty("json", paramStr));
                byte[] data = Encoding.UTF8.GetBytes(paramStr);
                myRequest = HttpWebRequest.Create(url) as HttpWebRequest;// 注意，这里不能写 myRequest = (HttpWebRequest)WebRequest.Create(url);
                DateTime start_time = DateTime.Now;
                //httpWeb.Headers.Add("Accept", "application/json");//添加消息头
                myRequest.Headers.Add("token", token);
                //if (!string.IsNullOrEmpty(token))
                //{
                //    myRequest.Headers.Add("token", token);
                //}
                myRequest.Timeout = 60000;
                myRequest.Method = "POST";
                myRequest.ContentType = "application/json";
                using (Stream stream = myRequest.GetRequestStream())
                {
                    stream.Write(data, 0, data.Length);

                }
                HttpWebResponse EhealthResp = myRequest.GetResponse() as HttpWebResponse;
                Stream EhealthResu = EhealthResp.GetResponseStream();
                StreamReader EhealthSr = new StreamReader(EhealthResu, Encoding.GetEncoding("UTF-8"));
                string finalStr = EhealthSr.ReadToEnd();
                r.result = true;
                r.html = finalStr;
                return r;
            }
            catch (Exception ex)
            {
                r.result = false;
                r.html = ex.ToString();
                if (myRequest != null) myRequest.Abort();
                if (myResponse != null) myResponse.Close();
                return r;
            }
        }
        #endregion
    }
    /// <summary>  
    /// 表单数据项  
    /// </summary>  
    public class FormItemModel
    {
        /// <summary>  
        /// 表单键，request["key"]  
        /// </summary>  
        public string Key { set; get; }
        /// <summary>  
        /// 表单值,上传文件时忽略，request["key"].value  
        /// </summary>  
        public string Value { set; get; }
        /// <summary>  
        /// 是否是文件  
        /// </summary>  
        public bool IsFile
        {
            get
            {
                if (FileContent == null || FileContent.Length == 0)
                    return false;

                if (FileContent != null && FileContent.Length > 0 && string.IsNullOrWhiteSpace(FileName))
                    throw new Exception("上传文件时 FileName 属性值不能为空");
                return true;
            }
        }
        /// <summary>  
        /// 上传的文件名  
        /// </summary>  
        public string FileName { set; get; }
        /// <summary>  
        /// 上传的文件内容  
        /// </summary>  
        public Stream FileContent { set; get; }
    }
    public class FormRequest
    {
        // https
        private static readonly string DefaultUserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";

        private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
        {
            return true; //总是接受     
        }
        /// <summary>  
        /// 使用Post方法获取字符串结果  
        /// </summary>  
        /// <param name="url"></param>  
        /// <param name="formItems">Post表单内容</param>  
        /// <param name="cookieContainer"></param>  
        /// <param name="timeOut">默认20秒</param>  
        /// <param name="encoding">响应内容的编码类型（默认utf-8）</param>  
        /// <returns></returns>  
        public static string PostForm(string url, List<FormItemModel> formItems, CookieContainer cookieContainer = null, string refererUrl = null, Encoding encoding = null, int timeOut = 20000)
        {
            HttpWebRequest request = null;
            //HTTPSQ请求  
            if (url.Substring(0, 8) == "https://")
            {
                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
            }

            request = WebRequest.Create(url) as HttpWebRequest;
            request.ProtocolVersion = HttpVersion.Version10;
            #region 初始化请求对象
            request.Method = "POST";
            request.Timeout = timeOut;
            //request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
            request.KeepAlive = true;
            //request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36";
            if (!string.IsNullOrEmpty(refererUrl))
                request.Referer = refererUrl;
            if (cookieContainer != null)
                request.CookieContainer = cookieContainer;
            #endregion

            string boundary = "----" + DateTime.Now.Ticks.ToString("x");//分隔符  
            request.ContentType = string.Format("multipart/form-data; boundary={0}", boundary);
            //请求流  
            var postStream = new MemoryStream();
            #region 处理Form表单请求内容
            //是否用Form上传文件  
            var formUploadFile = formItems != null && formItems.Count > 0;
            if (formUploadFile)
            {
                //文件数据模板  
                string fileFormdataTemplate =
                    "\r\n--" + boundary +
                    "\r\nContent-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"" +
                    "\r\nContent-Type: multipart/form-data" +
                    "\r\n\r\n";
                //文本数据模板  
                string dataFormdataTemplate =
                    "\r\n--" + boundary +
                    "\r\nContent-Disposition: form-data; name=\"{0}\"" +
                    "\r\n\r\n{1}";
                foreach (var item in formItems)
                {
                    string formdata = null;
                    if (item.IsFile)
                    {
                        //上传文件  
                        formdata = string.Format(
                            fileFormdataTemplate,
                            item.Key, //表单键  
                            item.FileName);
                    }
                    else
                    {
                        //上传文本  
                        formdata = string.Format(
                            dataFormdataTemplate,
                            item.Key,
                            item.Value);
                    }
                    LogUtil.Info(formdata);

                    //统一处理  
                    byte[] formdataBytes = null;
                    //第一行不需要换行  
                    if (postStream.Length == 0)
                        formdataBytes = Encoding.UTF8.GetBytes(formdata.Substring(2, formdata.Length - 2));
                    else
                        formdataBytes = Encoding.UTF8.GetBytes(formdata);
                    postStream.Write(formdataBytes, 0, formdataBytes.Length);

                    //写入文件内容  
                    if (item.FileContent != null && item.FileContent.Length > 0)
                    {
                        using (var stream = item.FileContent)
                        {
                            byte[] buffer = new byte[1024];
                            int bytesRead = 0;
                            while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) != 0)
                            {
                                postStream.Write(buffer, 0, bytesRead);
                            }
                        }
                    }
                }
                //结尾  
                var footer = Encoding.UTF8.GetBytes("\r\n--" + boundary + "--\r\n");
                postStream.Write(footer, 0, footer.Length);

                ////debug  
                //var bs = postStream.ToArray();
                //string s = Encoding.UTF8.GetString(bs);
                //LogUtil.Info("postStream:" + s);
            }
            else
            {
                request.ContentType = "application/json;charset=UTF-8";
            }
            #endregion

            request.ContentLength = postStream.Length;

            #region 输入二进制流
            if (postStream != null)
            {
                postStream.Position = 0;
                //直接写入流  
                Stream requestStream = request.GetRequestStream();

                byte[] buffer = new byte[1024];
                int bytesRead = 0;
                while ((bytesRead = postStream.Read(buffer, 0, buffer.Length)) != 0)
                {
                    requestStream.Write(buffer, 0, bytesRead);
                }

                ////debug  
                //postStream.Seek(0, SeekOrigin.Begin);  
                //StreamReader sr = new StreamReader(postStream);  
                //var postStr = sr.ReadToEnd();  
                postStream.Close();//关闭文件访问  
            }
            #endregion

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            if (cookieContainer != null)
            {
                response.Cookies = cookieContainer.GetCookies(response.ResponseUri);
            }

            using (Stream responseStream = response.GetResponseStream())
            {
                using (StreamReader myStreamReader = new StreamReader(responseStream, encoding ?? Encoding.UTF8))
                {
                    string retString = myStreamReader.ReadToEnd();
                    return retString;
                }
            }
        }
    }
    
}